1 Vergleich von Klassifikationsmethoden in simulierten EMA-Daten


“EMA_5.5” besteht aus je 5 MZP im Pre- und im Post-Intervall. Dies sind die ursprünglich simulierten EMA-Daten von N = 50 Personen (ursprünglich N = 100.000).

“EMA_30.30” besteht aus je 30 MZP im Pre- und im Post-Intervall. Diese wurden aus den ursprünglichen Simulationsdaten erweitert und umfassen dieselben N = 50 Personen.

“EMA_5.5_Window” besteht aus je 5 MZP im Pre- und im Post-Intervall, wobei diese (pro Person) jeweils als zusammenhängendes Intervall (Window) zufällig aus den Gesamt-Intervallen ausgewählt wurden. Die Stichprobe umfasst dieselben N = 50 Personen.

“EMA_5.5_Days” besteht aus je 5 MZP im Pre- und im Post-Intervall, wobei diese pro Person jeweils unzusammenhängend zufällig aus den Gesamt-Intervallen ausgewählt wurden. Die Stichprobe umfasst dieselben N = 50 Personen.

# Ausschluss von Personen ohne Varianz in min. einem MZP-Intervall

EMA_5.5 = EMA_5.5 %>% 
  filter(ind.pretestSD != 0 & ind.posttestSD != 0)

EMA_30.30 = EMA_30.30 %>% 
  filter(ind.pretestSD != 0 & ind.posttestSD != 0)


EMA_5.5 = EMA_5.5 %>% 
  filter(ID_orig %in% EMA_30.30$ID1_PRE)

EMA_30.30 = EMA_30.30 %>% 
  filter(ID1_PRE %in% EMA_5.5$ID_orig)

EMA_5.5 = EMA_5.5 %>% 
  add_column(., .before = "ID_orig", ID = 1:nrow(.))

EMA_30.30 = EMA_30.30 %>% 
  add_column(., .before = "ID1_PRE", ID = 1:nrow(.))
load("cor_04_k20/EMA_5.5_Window.RData")
load("cor_04_k20/EMA_5.5_Days.RData")

EMA_5.5_Window$PRE_Mean = apply(EMA_5.5_Window[pre_5mzp], 1, mean)
EMA_5.5_Window$POST_Mean = apply(EMA_5.5_Window[post_5mzp], 1, mean)
EMA_5.5_Window$MeanDiff = EMA_5.5_Window$PRE_Mean - EMA_5.5_Window$POST_Mean
EMA_5.5_Window$ind.pretestSD = apply(EMA_5.5_Window[pre_5mzp], 1, sd)
EMA_5.5_Window$ind.posttestSD = apply(EMA_5.5_Window[post_5mzp], 1, sd)

EMA_5.5_Days$PRE_Mean = apply(EMA_5.5_Days[pre_5mzp], 1, mean)
EMA_5.5_Days$POST_Mean = apply(EMA_5.5_Days[post_5mzp], 1, mean)
EMA_5.5_Days$MeanDiff = EMA_5.5_Days$PRE_Mean - EMA_5.5_Days$POST_Mean
EMA_5.5_Days$ind.pretestSD = apply(EMA_5.5_Days[pre_5mzp], 1, sd)
EMA_5.5_Days$ind.posttestSD = apply(EMA_5.5_Days[post_5mzp], 1, sd)
# Ausschluss von Personen ohne Varianz in min. einem MZP-Intervall
# sd(c(1,1,1,1,2)) = 0.4472136 = min. SD bei 5 (nicht gleichen) MZP
# sd(c(1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2)) = 0.1825742 = min. SD bei 30 (nicht gleichen) MZP

EMA_5.5_Window = EMA_5.5_Window %>% 
  filter(ind.pretestSD != 0 & ind.posttestSD != 0)

EMA_5.5_Days = EMA_5.5_Days %>% 
  filter(ind.pretestSD != 0 & ind.posttestSD != 0)

EMA_5.5 = EMA_5.5 %>% 
  filter(ID %in% EMA_30.30$ID & ID %in% EMA_5.5_Window$ID & ID %in% EMA_5.5_Days$ID)

EMA_30.30 = EMA_30.30 %>% 
  filter(ID %in% EMA_5.5$ID & ID %in% EMA_5.5_Window$ID & ID %in% EMA_5.5_Days$ID)

EMA_5.5_Window = EMA_5.5_Window %>% 
  filter(ID %in% EMA_5.5$ID & ID %in% EMA_30.30$ID & ID %in% EMA_5.5_Days$ID)

EMA_5.5_Days = EMA_5.5_Days %>% 
  filter(ID %in% EMA_5.5$ID & ID %in% EMA_30.30$ID & ID %in% EMA_5.5_Window$ID)

EMA_5.5$ID = 1:nrow(EMA_5.5)
EMA_30.30$ID = 1:nrow(EMA_30.30)
EMA_5.5_Window$ID = 1:nrow(EMA_5.5_Window)
EMA_5.5_Days$ID = 1:nrow(EMA_5.5_Days)

1.1 Drawing a Random Sample of n = 50

# or with slice_sample(n = 50)
rand = sample(EMA_5.5$ID, size = 50)

EMA_5.5 = EMA_5.5 %>% 
  filter(ID %in% rand)

EMA_30.30 = EMA_30.30 %>%
  filter(ID %in% rand)

EMA_5.5_Window = EMA_5.5_Window %>%
  filter(ID %in% rand)

EMA_5.5_Days = EMA_5.5_Days %>%
  filter(ID %in% rand)

1.2 Überblick über die simulierten Daten

Beispiel-Verläufe in den 4 untersuchten Datensets

1.2.1 Original-Simulationsdaten (je 5 MZP)

EMA_5.5 %>%
  within(., {ind.pretestSD = round(ind.pretestSD, digits = 2)
            ind.posttestSD = round(ind.posttestSD, digits = 2)}) %>% 
  head() %>% 
  kable() %>% 
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = FALSE) %>% 
  scroll_box(width = "100%")
ID ID_orig PRE1_1 PRE1_2 PRE1_3 PRE1_4 PRE1_5 POST1_1 POST1_2 POST1_3 POST1_4 POST1_5 PRE_Mean POST_Mean MeanDiff ind.pretestSD ind.posttestSD
259 299 6 6 6 7 11 15 12 5 9 9 7.2 10.0 -2.8 2.17 3.74
299 342 18 14 13 7 9 16 13 10 4 7 12.2 10.0 2.2 4.32 4.74
356 420 9 5 6 10 10 12 13 10 11 4 8.0 10.0 -2.0 2.35 3.54
481 564 10 11 16 13 13 2 11 10 8 6 12.6 7.4 5.2 2.30 3.58
634 741 14 9 8 9 9 15 3 14 7 12 9.8 10.2 -0.4 2.39 5.07
836 984 10 9 10 10 13 2 1 6 10 9 10.4 5.6 4.8 1.52 4.04


Pre-Post-Verläufe für 9 zufällig gezogene Personen

rand = sample(EMA_5.5$ID, 9)

x = tibble(ID = c(rep(rand[1],times=11),
                  rep(rand[2],times=11),
                  rep(rand[3],times=11),
                  rep(rand[4],times=11),
                  rep(rand[5],times=11),
                  rep(rand[6],times=11),
                  rep(rand[7],times=11),
                  rep(rand[8],times=11),
                  rep(rand[9],times=11)),
           MZP = rep(seq(as.Date("2020-01-01"), length.out=11, by="1 day"), times=9),
           Score = c(as.numeric(EMA_5.5[rand[1],pre_5mzp]), NA, as.numeric(EMA_5.5[rand[1],post_5mzp]),
                     as.numeric(EMA_5.5[rand[2],pre_5mzp]), NA, as.numeric(EMA_5.5[rand[2],post_5mzp]),
                     as.numeric(EMA_5.5[rand[3],pre_5mzp]), NA, as.numeric(EMA_5.5[rand[3],post_5mzp]),
                     as.numeric(EMA_5.5[rand[4],pre_5mzp]), NA, as.numeric(EMA_5.5[rand[4],post_5mzp]),
                     as.numeric(EMA_5.5[rand[5],pre_5mzp]), NA, as.numeric(EMA_5.5[rand[5],post_5mzp]),
                     as.numeric(EMA_5.5[rand[6],pre_5mzp]), NA, as.numeric(EMA_5.5[rand[6],post_5mzp]),
                     as.numeric(EMA_5.5[rand[7],pre_5mzp]), NA, as.numeric(EMA_5.5[rand[7],post_5mzp]),
                     as.numeric(EMA_5.5[rand[8],pre_5mzp]), NA, as.numeric(EMA_5.5[rand[8],post_5mzp]),
                     as.numeric(EMA_5.5[rand[9],pre_5mzp]), NA, as.numeric(EMA_5.5[rand[9],post_5mzp])))

x %>%
  group_by(ID) %>% 
  plot_time_series(MZP, Score,
    #.color_var = ID,           # for multiple lines in one plot
    #.color_lab = "ID",
    .facet_ncol = 3,
    .facet_scales = "fixed",
    .interactive = TRUE,
    .facet_collapse = FALSE,
    .smooth = TRUE,
    .smooth_degree = 2,
    .smooth_alpha = 0.5,
    .smooth_size = 0.2
  )
# don´t run this section (code for extremely computation-intense plots that I already stored as .RData and .jpg)
# repeated-measures scatter-boxplot-violin-histograms for individual PRE and POST means
# from van Langen (2020) Open-visualizations tutorial for repeated measures in R

# EMA_5.5
# converting my dataframes to use in the same ggplot structure:
EMA_5.5_ts = EMA_5.5 %>% 
  select(ID, PRE_Mean, POST_Mean) %>% 
  pivot_longer(!ID, names_to = "Interval", values_to = "Mean") %>% 
  mutate(ID = as.factor(ID),
         Interval = rep(c(1,2), times = nrow(EMA_5.5)))

save(EMA_5.5_ts, file = "Time Series Dataframes/k20_EMA_5.5_n50_ts.RData")

###

load("Time Series Dataframes/k20_EMA_5.5_n50_ts.RData")

# Repeated measures with box− and violin plots
EMA_5.5_ts$jit = jitter(EMA_5.5_ts$Interval, amount = .09)

Pre_Post_Box_Violin = ggplot(data = EMA_5.5_ts, aes(y = Mean)) +
  geom_point(data = EMA_5.5_ts %>% filter(Interval == "1"), aes(x = jit), color = "dodgerblue", size = 1,
             alpha = .5) +
  geom_point(data = EMA_5.5_ts %>% filter(Interval == "2"), aes(x = jit), color = "darkorange", size = 1,
             alpha = .5) +
  geom_line(aes(x = jit, group = ID), color = "lightgray", alpha = .05) +
  geom_half_boxplot(
    data = EMA_5.5_ts %>% filter(Interval == "1"), aes(x = Interval, y = Mean), position = position_nudge(x = -.25),
    side = "r", outlier.shape = NA, center = TRUE, errorbar.draw = TRUE, width = .1,
    fill = "dodgerblue", alpha = .5) +
  geom_half_boxplot(
    data = EMA_5.5_ts %>% filter(Interval == "2"), aes(x = Interval, y = Mean), position = position_nudge(x = .15),
    side = "r", outlier.shape = NA, center = TRUE, errorbar.draw = TRUE, width = .1,
    fill = "darkorange", alpha = .5) +
  geom_half_violin(
    data = EMA_5.5_ts %>% filter(Interval == "1"), aes(x = Interval, y = Mean), position = position_nudge(x = 1.3),
    side = "r", fill = "dodgerblue", alpha = .5, trim = FALSE) +
  geom_half_violin(
    data = EMA_5.5_ts %>% filter(Interval == "2"), aes(x = Interval, y = Mean), position = position_nudge(x = .3),
    side = "r", fill = "darkorange", alpha = .5, trim = FALSE) +
  scale_x_continuous(breaks = c(1,2), labels = c("PRE", "POST"), limits = c(0, 3)) +
  xlab("Interval") + ylab("PHQ-9 Mean Score") +
  #ggtitle("EMA Data (5+5 Timepoints): Individual Pre-Post Means") +
  #theme_classic() +
  theme_bw() +
  coord_cartesian(ylim = c(0, 24))

ggsave("Time Series Dataframes/k20_EMA_5.5_n50_Pre-Post_Box_Violin.jpg", plot = Pre_Post_Box_Violin, width = 6, height = 4)
save(Pre_Post_Box_Violin, file = "Time Series Dataframes/k20_EMA_5.5_n50_Pre_Post_Box_Violin.RData")


# Repeated measures with box− and violin plots and means + CIs
score_mean_1 = EMA_5.5_ts %>% filter(Interval == "1") %>% summarise(mean(Mean)) %>% as.numeric()
score_mean_2 = EMA_5.5_ts %>% filter(Interval == "2") %>% summarise(mean(Mean)) %>% as.numeric()
score_median1 = EMA_5.5_ts %>% filter(Interval == "1") %>% summarise(median(Mean)) %>% as.numeric()
score_median2 = EMA_5.5_ts %>% filter(Interval == "2") %>% summarise(median(Mean)) %>% as.numeric()
score_sd_1 = EMA_5.5_ts %>% filter(Interval == "1") %>% summarise(sd(Mean)) %>% as.numeric()
score_sd_2 = EMA_5.5_ts %>% filter(Interval == "2") %>% summarise(sd(Mean)) %>% as.numeric()
score_se_1 = score_sd_1/sqrt(nrow(EMA_5.5))
score_se_2 = score_sd_2/sqrt(nrow(EMA_5.5))
score_ci_1 = EMA_5.5_ts %>% filter(Interval == "1") %>% pull(Mean) %>% CI(., ci = 0.95)
score_ci_2 = EMA_5.5_ts %>% filter(Interval == "2") %>% pull(Mean) %>% CI(., ci = 0.95)
#Create data frame with 2 rows and 7 columns containing the descriptives
group = c("PRE", "POST")
N = c(nrow(EMA_5.5), nrow(EMA_5.5))
score_mean = c(score_mean_1, score_mean_2)
score_median = c(score_median1, score_median2)
sd = c(score_sd_1, score_sd_2)
se = c(score_se_1, score_se_2)
ci = c(as.numeric(score_ci_1[1] - score_ci_1[3]), as.numeric(score_ci_2[1] - score_ci_2[3]))
summary_df = data.frame(group, N, score_mean, score_median, sd, se, ci)

# EMA_5.5_ts$jit = jitter(EMA_5.5_ts$Interval, amount = .09)     #already created above
x_tick_means = c(.87, 2.13)

Pre_Post_Box_Violin_Mean_CI = ggplot(data = EMA_5.5_ts, aes(y = Mean)) +
  geom_point(data = EMA_5.5_ts %>% filter(Interval == "1"), aes(x = jit), color = "dodgerblue", size = 1,
             alpha = .6) +
  geom_point(data = EMA_5.5_ts %>% filter(Interval == "2"), aes(x = jit), color = "darkorange", size = 1,
             alpha = .6) +
  geom_line(aes(x = jit, group = ID), color = "lightgray", alpha = .05) +
  geom_half_boxplot(
    data = EMA_5.5_ts %>% filter(Interval == "1"), aes(x = Interval, y = Mean), position = position_nudge(x = -.28),
    side = "r", outlier.shape = NA, center = TRUE, errorbar.draw = FALSE, width = .2,
    fill = "dodgerblue") +
  geom_half_boxplot(
    data = EMA_5.5_ts %>% filter(Interval == "2"), aes(x = Interval, y = Mean), position = position_nudge(x = .18),
    side = "r", outlier.shape = NA, center = TRUE, errorbar.draw = FALSE, width = .2,
    fill = "darkorange") +
  geom_half_violin(
    data = EMA_5.5_ts %>% filter(Interval == "1"), aes(x = Interval, y = Mean), position = position_nudge(x = -.3),
    side = "l", fill = "dodgerblue") +
  geom_half_violin(
    data = EMA_5.5_ts %>% filter(Interval == "2"),aes(x = Interval, y = Mean), position = position_nudge(x = .3),
    side = "r", fill = "darkorange") +
  geom_point(data = EMA_5.5_ts %>% filter(Interval == "1"), aes(x = Interval, y = score_mean[1]),
             position = position_nudge(x = -.13), color = "dodgerblue", alpha = .6, size = 1.5) +
  geom_errorbar(data = EMA_5.5_ts %>% filter(Interval == "1"), aes(x = Interval, y = score_mean[1],
                                                 ymin = score_mean[1]-ci[1], ymax = score_mean[1]+ci[1]),
                position = position_nudge(-.13), color = "dodgerblue", width = 0.05, size = 0.4, alpha = .6) +
  geom_point(data = EMA_5.5_ts %>% filter(Interval == "2"), aes(x = Interval, y = score_mean[2]),
             position = position_nudge(x = .13), color = "darkorange", alpha = .6, size = 1.5)+
  geom_errorbar(data = EMA_5.5_ts %>% filter(Interval == "2"), aes(x = Interval, y = score_mean[2],
                                                 ymin = score_mean[2]-ci[2], ymax = score_mean[2]+ci[2]), 
                position = position_nudge(.13), color = "darkorange", width = 0.05, size = 0.4, alpha = .6) +
  geom_line(data = summary_df, aes(x = x_tick_means, y = score_mean), color = "gray", size = 1) +
  scale_x_continuous(breaks = c(1,2), labels = c("PRE", "POST"), limits = c(0, 3)) +
  xlab("Interval") + ylab("PHQ-9 Mean Score") +
  #ggtitle("EMA Data (5+5 Timepoints): Individual Pre-Post Means") +
  #theme_classic() +
  theme_bw() +
  coord_cartesian(ylim = c(0, 24))

ggsave("Time Series Dataframes/k20_EMA_5.5_n50_Pre-Post_Box_Violin_Mean+CI.jpg", plot = Pre_Post_Box_Violin_Mean_CI, width = 6, height = 4)
save(Pre_Post_Box_Violin_Mean_CI, file = "Time Series Dataframes/k20_EMA_5.5_n50_Pre_Post_Box_Violin_Mean_CI.RData")
#knitr::include_graphics("Time Series Dataframes/k20_EMA_5.5_n50_Pre-Post_Box_Violin.jpg")
knitr::include_graphics("Time Series Dataframes/k20_EMA_5.5_n50_Pre-Post_Box_Violin_Mean+CI.jpg")


1.2.2 Erweiterte Intervall-Daten (je 30 MZP)

EMA_30.30 %>% 
  select(-(ID1_PRE:ID6_POST)) %>% 
  within(., {ind.pretestSD = round(ind.pretestSD, digits = 2)
            ind.posttestSD = round(ind.posttestSD, digits = 2)}) %>% 
  head() %>% 
  kable() %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = FALSE) %>% 
  scroll_box(width = "100%")
ID PRE1_1 PRE1_2 PRE1_3 PRE1_4 PRE1_5 PRE1_6 PRE1_7 PRE1_8 PRE1_9 PRE1_10 PRE1_11 PRE1_12 PRE1_13 PRE1_14 PRE1_15 PRE1_16 PRE1_17 PRE1_18 PRE1_19 PRE1_20 PRE1_21 PRE1_22 PRE1_23 PRE1_24 PRE1_25 PRE1_26 PRE1_27 PRE1_28 PRE1_29 PRE1_30 POST1_1 POST1_2 POST1_3 POST1_4 POST1_5 POST1_6 POST1_7 POST1_8 POST1_9 POST1_10 POST1_11 POST1_12 POST1_13 POST1_14 POST1_15 POST1_16 POST1_17 POST1_18 POST1_19 POST1_20 POST1_21 POST1_22 POST1_23 POST1_24 POST1_25 POST1_26 POST1_27 POST1_28 POST1_29 POST1_30 PRE_Mean POST_Mean MeanDiff ind.pretestSD ind.posttestSD
259 6 6 6 7 11 10 4 8 7 7 7 10 8 7 4 10 9 5 6 6 6 6 11 6 7 8 9 6 4 9 15 12 5 9 9 8 13 15 7 7 6 6 12 12 14 8 11 11 15 5 9 13 11 13 4 7 7 13 15 8 7.2 10.0 -2.8 1.97 3.40
299 18 14 13 7 9 9 9 10 14 19 15 15 8 7 16 18 13 11 13 6 18 13 14 7 9 14 19 10 9 9 16 13 10 4 7 15 12 13 6 4 6 18 9 10 7 10 8 4 17 11 14 11 10 13 2 10 3 9 12 16 12.2 10.0 2.2 3.93 4.32
356 9 5 6 10 10 6 6 7 11 10 9 10 9 4 8 11 7 6 6 10 7 8 7 12 6 9 8 4 10 9 12 13 10 11 4 8 10 9 16 7 15 10 10 10 5 6 14 13 10 7 6 9 15 12 8 15 10 10 5 10 8.0 10.0 -2.0 2.13 3.22
481 10 11 16 13 13 12 14 15 13 9 13 15 14 12 9 10 11 16 13 13 14 13 12 15 9 12 14 15 9 13 2 11 10 8 6 11 8 10 2 6 11 10 6 8 2 4 12 10 7 4 3 7 5 11 11 3 7 11 11 5 12.6 7.4 5.2 2.09 3.25
634 14 9 8 9 9 6 11 11 9 12 11 11 9 6 12 10 8 11 7 13 8 11 13 7 10 9 9 14 8 9 15 3 14 7 12 15 16 9 6 5 12 15 14 7 3 17 3 9 12 10 8 6 9 19 9 9 19 8 9 6 9.8 10.2 -0.4 2.17 4.61
836 10 9 10 10 13 11 11 12 10 8 8 11 12 10 11 10 9 10 10 13 12 9 9 12 10 10 12 9 9 12 2 1 6 10 9 12 3 2 7 4 2 4 7 12 3 1 2 6 9 10 2 7 3 4 12 1 5 4 12 6 10.4 5.6 4.8 1.38 3.67


Pre-Post-Verläufe für 9 zufällig gezogene Personen

rand = sample(EMA_30.30$ID, 9)

x = tibble(ID = c(rep(rand[1],times=61),
                     rep(rand[2],times=61),
                     rep(rand[3],times=61),
                     rep(rand[4],times=61),
                     rep(rand[5],times=61),
                     rep(rand[6],times=61),
                     rep(rand[7],times=61),
                     rep(rand[8],times=61),
                     rep(rand[9],times=61)),
              MZP = rep(seq(as.Date("2020-01-01"), length.out=61, by="1 day"), times=9),
              Score = c(as.numeric(EMA_30.30[rand[1],pre_30mzp]), NA, as.numeric(EMA_30.30[rand[1],post_30mzp]),
                        as.numeric(EMA_30.30[rand[2],pre_30mzp]), NA, as.numeric(EMA_30.30[rand[2],post_30mzp]),
                        as.numeric(EMA_30.30[rand[3],pre_30mzp]), NA, as.numeric(EMA_30.30[rand[3],post_30mzp]),
                        as.numeric(EMA_30.30[rand[4],pre_30mzp]), NA, as.numeric(EMA_30.30[rand[4],post_30mzp]),
                        as.numeric(EMA_30.30[rand[5],pre_30mzp]), NA, as.numeric(EMA_30.30[rand[5],post_30mzp]),
                        as.numeric(EMA_30.30[rand[6],pre_30mzp]), NA, as.numeric(EMA_30.30[rand[6],post_30mzp]),
                        as.numeric(EMA_30.30[rand[7],pre_30mzp]), NA, as.numeric(EMA_30.30[rand[7],post_30mzp]),
                        as.numeric(EMA_30.30[rand[8],pre_30mzp]), NA, as.numeric(EMA_30.30[rand[8],post_30mzp]),
                        as.numeric(EMA_30.30[rand[9],pre_30mzp]), NA, as.numeric(EMA_30.30[rand[9],post_30mzp])))

x %>%
  group_by(ID) %>% 
  plot_time_series(MZP, Score,
    #.color_var = ID,           # for multiple lines in one plot
    #.color_lab = "ID",
    .facet_ncol = 3,
    .facet_scales = "fixed",
    .interactive = TRUE,
    .facet_collapse = FALSE,
    .smooth = TRUE,
    .smooth_degree = 2,
    .smooth_alpha = 0.5,
    .smooth_size = 0.2
  )
# don´t run this section (code for extremely computation-intense plots that I already stored as .RData and .jpg)
# repeated-measures scatter-boxplot-violin-histograms for individual PRE and POST means
# from van Langen (2020) Open-visualizations tutorial for repeated measures in R

# EMA_30.30
# converting my dataframes to use in the same ggplot structure:
EMA_30.30_ts = EMA_30.30 %>% 
  select(ID, PRE_Mean, POST_Mean) %>% 
  pivot_longer(!ID, names_to = "Interval", values_to = "Mean") %>% 
  mutate(ID = as.factor(ID),
         Interval = rep(c(1,2), times = nrow(EMA_30.30)))

save(EMA_30.30_ts, file = "Time Series Dataframes/k20_EMA_30.30_n50_ts.RData")

###

load("Time Series Dataframes/k20_EMA_30.30_n50_ts.RData")

# Repeated measures with box− and violin plots
EMA_30.30_ts$jit = jitter(EMA_30.30_ts$Interval, amount = .09)

Pre_Post_Box_Violin = ggplot(data = EMA_30.30_ts, aes(y = Mean)) +
  geom_point(data = EMA_30.30_ts %>% filter(Interval == "1"), aes(x = jit), color = "dodgerblue", size = 1,
             alpha = .5) +
  geom_point(data = EMA_30.30_ts %>% filter(Interval == "2"), aes(x = jit), color = "darkorange", size = 1,
             alpha = .5) +
  geom_line(aes(x = jit, group = ID), color = "lightgray", alpha = .05) +
  geom_half_boxplot(
    data = EMA_30.30_ts %>% filter(Interval == "1"), aes(x = Interval, y = Mean), position = position_nudge(x = -.25),
    side = "r", outlier.shape = NA, center = TRUE, errorbar.draw = TRUE, width = .1,
    fill = "dodgerblue", alpha = .5) +
  geom_half_boxplot(
    data = EMA_30.30_ts %>% filter(Interval == "2"), aes(x = Interval, y = Mean), position = position_nudge(x = .15),
    side = "r", outlier.shape = NA, center = TRUE, errorbar.draw = TRUE, width = .1,
    fill = "darkorange", alpha = .5) +
  geom_half_violin(
    data = EMA_30.30_ts %>% filter(Interval == "1"), aes(x = Interval, y = Mean), position = position_nudge(x = 1.3),
    side = "r", fill = "dodgerblue", alpha = .5, trim = FALSE) +
  geom_half_violin(
    data = EMA_30.30_ts %>% filter(Interval == "2"), aes(x = Interval, y = Mean), position = position_nudge(x = .3),
    side = "r", fill = "darkorange", alpha = .5, trim = FALSE) +
  scale_x_continuous(breaks = c(1,2), labels = c("PRE", "POST"), limits = c(0, 3)) +
  xlab("Interval") + ylab("PHQ-9 Mean Score") +
  #ggtitle("EMA Data (30+30 Timepoints): Individual Pre-Post Means") +
  #theme_classic() +
  theme_bw() +
  coord_cartesian(ylim = c(0, 24))

ggsave("Time Series Dataframes/k20_EMA_30.30_n50_Pre-Post_Box_Violin.jpg", plot = Pre_Post_Box_Violin, width = 6, height = 4)
save(Pre_Post_Box_Violin, file = "Time Series Dataframes/k20_EMA_30.30_n50_Pre_Post_Box_Violin.RData")


# Repeated measures with box− and violin plots and means + CIs
score_mean_1 = EMA_30.30_ts %>% filter(Interval == "1") %>% summarise(mean(Mean)) %>% as.numeric()
score_mean_2 = EMA_30.30_ts %>% filter(Interval == "2") %>% summarise(mean(Mean)) %>% as.numeric()
score_median1 = EMA_30.30_ts %>% filter(Interval == "1") %>% summarise(median(Mean)) %>% as.numeric()
score_median2 = EMA_30.30_ts %>% filter(Interval == "2") %>% summarise(median(Mean)) %>% as.numeric()
score_sd_1 = EMA_30.30_ts %>% filter(Interval == "1") %>% summarise(sd(Mean)) %>% as.numeric()
score_sd_2 = EMA_30.30_ts %>% filter(Interval == "2") %>% summarise(sd(Mean)) %>% as.numeric()
score_se_1 = score_sd_1/sqrt(nrow(EMA_30.30))
score_se_2 = score_sd_2/sqrt(nrow(EMA_30.30))
score_ci_1 = EMA_30.30_ts %>% filter(Interval == "1") %>% pull(Mean) %>% CI(., ci = 0.95)
score_ci_2 = EMA_30.30_ts %>% filter(Interval == "2") %>% pull(Mean) %>% CI(., ci = 0.95)
#Create data frame with 2 rows and 7 columns containing the descriptives
group = c("PRE", "POST")
N = c(nrow(EMA_30.30), nrow(EMA_30.30))
score_mean = c(score_mean_1, score_mean_2)
score_median = c(score_median1, score_median2)
sd = c(score_sd_1, score_sd_2)
se = c(score_se_1, score_se_2)
ci = c(as.numeric(score_ci_1[1] - score_ci_1[3]), as.numeric(score_ci_2[1] - score_ci_2[3]))
summary_df = data.frame(group, N, score_mean, score_median, sd, se, ci)

# EMA_30.30_ts$jit = jitter(EMA_30.30_ts$Interval, amount = .09)     #already created above
x_tick_means = c(.87, 2.13)

Pre_Post_Box_Violin_Mean_CI = ggplot(data = EMA_30.30_ts, aes(y = Mean)) +
  geom_point(data = EMA_30.30_ts %>% filter(Interval == "1"), aes(x = jit), color = "dodgerblue", size = 1,
             alpha = .6) +
  geom_point(data = EMA_30.30_ts %>% filter(Interval == "2"), aes(x = jit), color = "darkorange", size = 1,
             alpha = .6) +
  geom_line(aes(x = jit, group = ID), color = "lightgray", alpha = .05) +
  geom_half_boxplot(
    data = EMA_30.30_ts %>% filter(Interval == "1"), aes(x = Interval, y = Mean), position = position_nudge(x = -.28),
    side = "r", outlier.shape = NA, center = TRUE, errorbar.draw = FALSE, width = .2,
    fill = "dodgerblue") +
  geom_half_boxplot(
    data = EMA_30.30_ts %>% filter(Interval == "2"), aes(x = Interval, y = Mean), position = position_nudge(x = .18),
    side = "r", outlier.shape = NA, center = TRUE, errorbar.draw = FALSE, width = .2,
    fill = "darkorange") +
  geom_half_violin(
    data = EMA_30.30_ts %>% filter(Interval == "1"), aes(x = Interval, y = Mean), position = position_nudge(x = -.3),
    side = "l", fill = "dodgerblue") +
  geom_half_violin(
    data = EMA_30.30_ts %>% filter(Interval == "2"),aes(x = Interval, y = Mean), position = position_nudge(x = .3),
    side = "r", fill = "darkorange") +
  geom_point(data = EMA_30.30_ts %>% filter(Interval == "1"), aes(x = Interval, y = score_mean[1]),
             position = position_nudge(x = -.13), color = "dodgerblue", alpha = .6, size = 1.5) +
  geom_errorbar(data = EMA_30.30_ts %>% filter(Interval == "1"), aes(x = Interval, y = score_mean[1],
                                                 ymin = score_mean[1]-ci[1], ymax = score_mean[1]+ci[1]),
                position = position_nudge(-.13), color = "dodgerblue", width = 0.05, size = 0.4, alpha = .6) +
  geom_point(data = EMA_30.30_ts %>% filter(Interval == "2"), aes(x = Interval, y = score_mean[2]),
             position = position_nudge(x = .13), color = "darkorange", alpha = .6, size = 1.5)+
  geom_errorbar(data = EMA_30.30_ts %>% filter(Interval == "2"), aes(x = Interval, y = score_mean[2],
                                                 ymin = score_mean[2]-ci[2], ymax = score_mean[2]+ci[2]), 
                position = position_nudge(.13), color = "darkorange", width = 0.05, size = 0.4, alpha = .6) +
  geom_line(data = summary_df, aes(x = x_tick_means, y = score_mean), color = "gray", size = 1) +
  scale_x_continuous(breaks = c(1,2), labels = c("PRE", "POST"), limits = c(0, 3)) +
  xlab("Interval") + ylab("PHQ-9 Mean Score") +
  #ggtitle("EMA Data (30+30 Timepoints): Individual Pre-Post Means") +
  #theme_classic() +
  theme_bw() +
  coord_cartesian(ylim = c(0, 24))

ggsave("Time Series Dataframes/k20_EMA_30.30_n50_Pre-Post_Box_Violin_Mean+CI.jpg", plot = Pre_Post_Box_Violin_Mean_CI, width = 6, height = 4)
save(Pre_Post_Box_Violin_Mean_CI, file = "Time Series Dataframes/k20_EMA_30.30_n50_Pre_Post_Box_Violin_Mean_CI.RData")
#knitr::include_graphics("Time Series Dataframes/k20_EMA_30.30_n50_Pre-Post_Box_Violin.jpg")
knitr::include_graphics("Time Series Dataframes/k20_EMA_30.30_n50_Pre-Post_Box_Violin_Mean+CI.jpg")


1.2.3 Zufallsauswahl: Random Window (je 5 MZP)

EMA_5.5_Window %>%
  within(., {ind.pretestSD = round(ind.pretestSD, digits = 2)
            ind.posttestSD = round(ind.posttestSD, digits = 2)}) %>% 
  head() %>% 
  kable() %>% 
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = FALSE) %>% 
  scroll_box(width = "100%")
ID Pre_MZP1 Pre_MZP2 Pre_MZP3 Pre_MZP4 Pre_MZP5 Post_MZP1 Post_MZP2 Post_MZP3 Post_MZP4 Post_MZP5 PRE1_1 PRE1_2 PRE1_3 PRE1_4 PRE1_5 POST1_1 POST1_2 POST1_3 POST1_4 POST1_5 PRE_Mean POST_Mean MeanDiff ind.pretestSD ind.posttestSD
259 PRE1_2 PRE1_3 PRE1_4 PRE1_5 PRE1_6 POST1_7 POST1_8 POST1_9 POST1_10 POST1_11 6 6 7 11 10 13 15 7 7 6 8.0 9.6 -1.6 2.35 4.10
299 PRE1_17 PRE1_18 PRE1_19 PRE1_20 PRE1_21 POST1_26 POST1_27 POST1_28 POST1_29 POST1_30 13 11 13 6 18 10 3 9 12 16 12.2 10.0 2.2 4.32 4.74
356 PRE1_3 PRE1_4 PRE1_5 PRE1_6 PRE1_7 POST1_26 POST1_27 POST1_28 POST1_29 POST1_30 6 10 10 6 6 15 10 10 5 10 7.6 10.0 -2.4 2.19 3.54
481 PRE1_3 PRE1_4 PRE1_5 PRE1_6 PRE1_7 POST1_11 POST1_12 POST1_13 POST1_14 POST1_15 16 13 13 12 14 11 10 6 8 2 13.6 7.4 6.2 1.52 3.58
634 PRE1_24 PRE1_25 PRE1_26 PRE1_27 PRE1_28 POST1_25 POST1_26 POST1_27 POST1_28 POST1_29 7 10 9 9 14 9 9 19 8 9 9.8 10.8 -1.0 2.59 4.60
836 PRE1_22 PRE1_23 PRE1_24 PRE1_25 PRE1_26 POST1_14 POST1_15 POST1_16 POST1_17 POST1_18 9 9 12 10 10 12 3 1 2 6 10.0 4.8 5.2 1.22 4.44


Pre-Post-Verläufe für 9 zufällig gezogene Personen

rand = sample(EMA_5.5_Window$ID, 9)

x = tibble(ID = c(rep(rand[1],times=11),
                  rep(rand[2],times=11),
                  rep(rand[3],times=11),
                  rep(rand[4],times=11),
                  rep(rand[5],times=11),
                  rep(rand[6],times=11),
                  rep(rand[7],times=11),
                  rep(rand[8],times=11),
                  rep(rand[9],times=11)),
           MZP = rep(seq(as.Date("2020-01-01"), length.out=11, by="1 day"), times=9),
           Score = c(as.numeric(EMA_5.5_Window[rand[1],pre_5mzp]), NA, as.numeric(EMA_5.5_Window[rand[1],post_5mzp]),
                     as.numeric(EMA_5.5_Window[rand[2],pre_5mzp]), NA, as.numeric(EMA_5.5_Window[rand[2],post_5mzp]),
                     as.numeric(EMA_5.5_Window[rand[3],pre_5mzp]), NA, as.numeric(EMA_5.5_Window[rand[3],post_5mzp]),
                     as.numeric(EMA_5.5_Window[rand[4],pre_5mzp]), NA, as.numeric(EMA_5.5_Window[rand[4],post_5mzp]),
                     as.numeric(EMA_5.5_Window[rand[5],pre_5mzp]), NA, as.numeric(EMA_5.5_Window[rand[5],post_5mzp]),
                     as.numeric(EMA_5.5_Window[rand[6],pre_5mzp]), NA, as.numeric(EMA_5.5_Window[rand[6],post_5mzp]),
                     as.numeric(EMA_5.5_Window[rand[7],pre_5mzp]), NA, as.numeric(EMA_5.5_Window[rand[7],post_5mzp]),
                     as.numeric(EMA_5.5_Window[rand[8],pre_5mzp]), NA, as.numeric(EMA_5.5_Window[rand[8],post_5mzp]),
                     as.numeric(EMA_5.5_Window[rand[9],pre_5mzp]), NA, as.numeric(EMA_5.5_Window[rand[9],post_5mzp])))

x %>%
  group_by(ID) %>% 
  plot_time_series(MZP, Score,
    #.color_var = ID,           # for multiple lines in one plot
    #.color_lab = "ID",
    .facet_ncol = 3,
    .facet_scales = "fixed",
    .interactive = TRUE,
    .facet_collapse = FALSE,
    .smooth = TRUE,
    .smooth_degree = 2,
    .smooth_alpha = 0.5,
    .smooth_size = 0.2
  )
# don´t run this section (code for extremely computation-intense plots that I already stored as .RData and .jpg)
# repeated-measures scatter-boxplot-violin-histograms for individual PRE and POST means
# from van Langen (2020) Open-visualizations tutorial for repeated measures in R

# EMA_5.5_Window
# converting my dataframes to use in the same ggplot structure:
EMA_5.5_Window_ts = EMA_5.5_Window %>% 
  select(ID, PRE_Mean, POST_Mean) %>% 
  pivot_longer(!ID, names_to = "Interval", values_to = "Mean") %>% 
  mutate(ID = as.factor(ID),
         Interval = rep(c(1,2), times = nrow(EMA_5.5_Window)))

save(EMA_5.5_Window_ts, file = "Time Series Dataframes/k20_EMA_5.5_Window_n50_ts.RData")

###

load("Time Series Dataframes/k20_EMA_5.5_Window_n50_ts.RData")

# Repeated measures with box− and violin plots
EMA_5.5_Window_ts$jit = jitter(EMA_5.5_Window_ts$Interval, amount = .09)

Pre_Post_Box_Violin = ggplot(data = EMA_5.5_Window_ts, aes(y = Mean)) +
  geom_point(data = EMA_5.5_Window_ts %>% filter(Interval == "1"), aes(x = jit), color = "dodgerblue", size = 1,
             alpha = .5) +
  geom_point(data = EMA_5.5_Window_ts %>% filter(Interval == "2"), aes(x = jit), color = "darkorange", size = 1,
             alpha = .5) +
  geom_line(aes(x = jit, group = ID), color = "lightgray", alpha = .05) +
  geom_half_boxplot(
    data = EMA_5.5_Window_ts %>% filter(Interval == "1"), aes(x = Interval, y = Mean), position = position_nudge(x = -.25),
    side = "r", outlier.shape = NA, center = TRUE, errorbar.draw = TRUE, width = .1,
    fill = "dodgerblue", alpha = .5) +
  geom_half_boxplot(
    data = EMA_5.5_Window_ts %>% filter(Interval == "2"), aes(x = Interval, y = Mean), position = position_nudge(x = .15),
    side = "r", outlier.shape = NA, center = TRUE, errorbar.draw = TRUE, width = .1,
    fill = "darkorange", alpha = .5) +
  geom_half_violin(
    data = EMA_5.5_Window_ts %>% filter(Interval == "1"), aes(x = Interval, y = Mean), position = position_nudge(x = 1.3),
    side = "r", fill = "dodgerblue", alpha = .5, trim = FALSE) +
  geom_half_violin(
    data = EMA_5.5_Window_ts %>% filter(Interval == "2"), aes(x = Interval, y = Mean), position = position_nudge(x = .3),
    side = "r", fill = "darkorange", alpha = .5, trim = FALSE) +
  scale_x_continuous(breaks = c(1,2), labels = c("PRE", "POST"), limits = c(0, 3)) +
  xlab("Interval") + ylab("PHQ-9 Mean Score") +
  #ggtitle("EMA Data (5+5 Timepoint Random Windows): Individual Pre-Post Means") +
  #theme_classic() +
  theme_bw() +
  coord_cartesian(ylim = c(0, 24))

ggsave("Time Series Dataframes/k20_EMA_5.5_Window_n50_Pre-Post_Box_Violin.jpg", plot = Pre_Post_Box_Violin, width = 6, height = 4)
save(Pre_Post_Box_Violin, file = "Time Series Dataframes/k20_EMA_5.5_Window_n50_Pre_Post_Box_Violin.RData")


# Repeated measures with box− and violin plots and means + CIs
score_mean_1 = EMA_5.5_Window_ts %>% filter(Interval == "1") %>% summarise(mean(Mean)) %>% as.numeric()
score_mean_2 = EMA_5.5_Window_ts %>% filter(Interval == "2") %>% summarise(mean(Mean)) %>% as.numeric()
score_median1 = EMA_5.5_Window_ts %>% filter(Interval == "1") %>% summarise(median(Mean)) %>% as.numeric()
score_median2 = EMA_5.5_Window_ts %>% filter(Interval == "2") %>% summarise(median(Mean)) %>% as.numeric()
score_sd_1 = EMA_5.5_Window_ts %>% filter(Interval == "1") %>% summarise(sd(Mean)) %>% as.numeric()
score_sd_2 = EMA_5.5_Window_ts %>% filter(Interval == "2") %>% summarise(sd(Mean)) %>% as.numeric()
score_se_1 = score_sd_1/sqrt(nrow(EMA_5.5_Window))
score_se_2 = score_sd_2/sqrt(nrow(EMA_5.5_Window))
score_ci_1 = EMA_5.5_Window_ts %>% filter(Interval == "1") %>% pull(Mean) %>% CI(., ci = 0.95)
score_ci_2 = EMA_5.5_Window_ts %>% filter(Interval == "2") %>% pull(Mean) %>% CI(., ci = 0.95)
#Create data frame with 2 rows and 7 columns containing the descriptives
group = c("PRE", "POST")
N = c(nrow(EMA_5.5_Window), nrow(EMA_5.5_Window))
score_mean = c(score_mean_1, score_mean_2)
score_median = c(score_median1, score_median2)
sd = c(score_sd_1, score_sd_2)
se = c(score_se_1, score_se_2)
ci = c(as.numeric(score_ci_1[1] - score_ci_1[3]), as.numeric(score_ci_2[1] - score_ci_2[3]))
summary_df = data.frame(group, N, score_mean, score_median, sd, se, ci)

# EMA_5.5_Window_ts$jit = jitter(EMA_5.5_Window_ts$Interval, amount = .09)     #already created above
x_tick_means = c(.87, 2.13)

Pre_Post_Box_Violin_Mean_CI = ggplot(data = EMA_5.5_Window_ts, aes(y = Mean)) +
  geom_point(data = EMA_5.5_Window_ts %>% filter(Interval == "1"), aes(x = jit), color = "dodgerblue", size = 1,
             alpha = .6) +
  geom_point(data = EMA_5.5_Window_ts %>% filter(Interval == "2"), aes(x = jit), color = "darkorange", size = 1,
             alpha = .6) +
  geom_line(aes(x = jit, group = ID), color = "lightgray", alpha = .05) +
  geom_half_boxplot(
    data = EMA_5.5_Window_ts %>% filter(Interval == "1"), aes(x = Interval, y = Mean), position = position_nudge(x = -.28),
    side = "r", outlier.shape = NA, center = TRUE, errorbar.draw = FALSE, width = .2,
    fill = "dodgerblue") +
  geom_half_boxplot(
    data = EMA_5.5_Window_ts %>% filter(Interval == "2"), aes(x = Interval, y = Mean), position = position_nudge(x = .18),
    side = "r", outlier.shape = NA, center = TRUE, errorbar.draw = FALSE, width = .2,
    fill = "darkorange") +
  geom_half_violin(
    data = EMA_5.5_Window_ts %>% filter(Interval == "1"), aes(x = Interval, y = Mean), position = position_nudge(x = -.3),
    side = "l", fill = "dodgerblue") +
  geom_half_violin(
    data = EMA_5.5_Window_ts %>% filter(Interval == "2"),aes(x = Interval, y = Mean), position = position_nudge(x = .3),
    side = "r", fill = "darkorange") +
  geom_point(data = EMA_5.5_Window_ts %>% filter(Interval == "1"), aes(x = Interval, y = score_mean[1]),
             position = position_nudge(x = -.13), color = "dodgerblue", alpha = .6, size = 1.5) +
  geom_errorbar(data = EMA_5.5_Window_ts %>% filter(Interval == "1"), aes(x = Interval, y = score_mean[1],
                                                 ymin = score_mean[1]-ci[1], ymax = score_mean[1]+ci[1]),
                position = position_nudge(-.13), color = "dodgerblue", width = 0.05, size = 0.4, alpha = .6) +
  geom_point(data = EMA_5.5_Window_ts %>% filter(Interval == "2"), aes(x = Interval, y = score_mean[2]),
             position = position_nudge(x = .13), color = "darkorange", alpha = .6, size = 1.5)+
  geom_errorbar(data = EMA_5.5_Window_ts %>% filter(Interval == "2"), aes(x = Interval, y = score_mean[2],
                                                 ymin = score_mean[2]-ci[2], ymax = score_mean[2]+ci[2]), 
                position = position_nudge(.13), color = "darkorange", width = 0.05, size = 0.4, alpha = .6) +
  geom_line(data = summary_df, aes(x = x_tick_means, y = score_mean), color = "gray", size = 1) +
  scale_x_continuous(breaks = c(1,2), labels = c("PRE", "POST"), limits = c(0, 3)) +
  xlab("Interval") + ylab("PHQ-9 Mean Score") +
  #ggtitle("EMA Data (5+5 Timepoint Random Windows): Individual Pre-Post Means") +
  #theme_classic() +
  theme_bw() +
  coord_cartesian(ylim = c(0, 24))

ggsave("Time Series Dataframes/k20_EMA_5.5_Window_n50_Pre-Post_Box_Violin_Mean+CI.jpg", plot = Pre_Post_Box_Violin_Mean_CI, width = 6, height = 4)
save(Pre_Post_Box_Violin_Mean_CI, file = "Time Series Dataframes/k20_EMA_5.5_Window_n50_Pre_Post_Box_Violin_Mean_CI.RData")
#knitr::include_graphics("Time Series Dataframes/k20_EMA_5.5_Window_n50_Pre-Post_Box_Violin.jpg")
knitr::include_graphics("Time Series Dataframes/k20_EMA_5.5_Window_n50_Pre-Post_Box_Violin_Mean+CI.jpg")


1.2.4 Zufallsauswahl: Random Days (je 5 MZP)

EMA_5.5_Days %>%
  within(., {ind.pretestSD = round(ind.pretestSD, digits = 2)
            ind.posttestSD = round(ind.posttestSD, digits = 2)}) %>% 
  head() %>% 
  kable() %>% 
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = FALSE) %>% 
  scroll_box(width = "100%")
ID Pre_MZP1 Pre_MZP2 Pre_MZP3 Pre_MZP4 Pre_MZP5 Post_MZP1 Post_MZP2 Post_MZP3 Post_MZP4 Post_MZP5 PRE1_1 PRE1_2 PRE1_3 PRE1_4 PRE1_5 POST1_1 POST1_2 POST1_3 POST1_4 POST1_5 PRE_Mean POST_Mean MeanDiff ind.pretestSD ind.posttestSD
259 PRE1_7 PRE1_11 PRE1_12 PRE1_19 PRE1_24 POST1_1 POST1_9 POST1_17 POST1_21 POST1_29 4 7 10 6 6 15 7 11 9 15 6.6 11.4 -4.8 2.19 3.58
299 PRE1_4 PRE1_7 PRE1_19 PRE1_26 PRE1_28 POST1_12 POST1_22 POST1_25 POST1_26 POST1_27 7 9 13 14 10 18 11 2 10 3 10.6 8.8 1.8 2.88 6.53
356 PRE1_4 PRE1_11 PRE1_15 PRE1_20 PRE1_24 POST1_2 POST1_6 POST1_8 POST1_10 POST1_20 10 9 8 10 12 13 8 9 7 7 9.8 8.8 1.0 1.48 2.49
481 PRE1_5 PRE1_15 PRE1_24 PRE1_25 PRE1_26 POST1_2 POST1_15 POST1_16 POST1_21 POST1_22 13 9 15 9 12 11 2 4 3 7 11.6 5.4 6.2 2.61 3.65
634 PRE1_6 PRE1_10 PRE1_11 PRE1_17 PRE1_21 POST1_9 POST1_13 POST1_18 POST1_20 POST1_30 6 12 11 8 8 6 14 9 10 6 9.0 9.0 0.0 2.45 3.32
836 PRE1_7 PRE1_16 PRE1_22 PRE1_25 PRE1_28 POST1_3 POST1_6 POST1_8 POST1_22 POST1_26 11 10 9 10 9 6 12 2 7 1 9.8 5.6 4.2 0.84 4.39


Pre-Post-Verläufe für 9 zufällig gezogene Personen

rand = sample(EMA_5.5_Days$ID, 9)

x = tibble(ID = c(rep(rand[1],times=11),
                  rep(rand[2],times=11),
                  rep(rand[3],times=11),
                  rep(rand[4],times=11),
                  rep(rand[5],times=11),
                  rep(rand[6],times=11),
                  rep(rand[7],times=11),
                  rep(rand[8],times=11),
                  rep(rand[9],times=11)),
           MZP = rep(seq(as.Date("2020-01-01"), length.out=11, by="1 day"), times=9),
           Score = c(as.numeric(EMA_5.5_Days[rand[1],pre_5mzp]), NA, as.numeric(EMA_5.5_Days[rand[1],post_5mzp]),
                     as.numeric(EMA_5.5_Days[rand[2],pre_5mzp]), NA, as.numeric(EMA_5.5_Days[rand[2],post_5mzp]),
                     as.numeric(EMA_5.5_Days[rand[3],pre_5mzp]), NA, as.numeric(EMA_5.5_Days[rand[3],post_5mzp]),
                     as.numeric(EMA_5.5_Days[rand[4],pre_5mzp]), NA, as.numeric(EMA_5.5_Days[rand[4],post_5mzp]),
                     as.numeric(EMA_5.5_Days[rand[5],pre_5mzp]), NA, as.numeric(EMA_5.5_Days[rand[5],post_5mzp]),
                     as.numeric(EMA_5.5_Days[rand[6],pre_5mzp]), NA, as.numeric(EMA_5.5_Days[rand[6],post_5mzp]),
                     as.numeric(EMA_5.5_Days[rand[7],pre_5mzp]), NA, as.numeric(EMA_5.5_Days[rand[7],post_5mzp]),
                     as.numeric(EMA_5.5_Days[rand[8],pre_5mzp]), NA, as.numeric(EMA_5.5_Days[rand[8],post_5mzp]),
                     as.numeric(EMA_5.5_Days[rand[9],pre_5mzp]), NA, as.numeric(EMA_5.5_Days[rand[9],post_5mzp])))

x %>%
  group_by(ID) %>% 
  plot_time_series(MZP, Score,
    #.color_var = ID,           # for multiple lines in one plot
    #.color_lab = "ID",
    .facet_ncol = 3,
    .facet_scales = "fixed",
    .interactive = TRUE,
    .facet_collapse = FALSE,
    .smooth = TRUE,
    .smooth_degree = 2,
    .smooth_alpha = 0.5,
    .smooth_size = 0.2
  )
# don´t run this section (code for extremely computation-intense plots that I already stored as .RData and .jpg)
# repeated-measures scatter-boxplot-violin-histograms for individual PRE and POST means
# from van Langen (2020) Open-visualizations tutorial for repeated measures in R

# EMA_5.5_Days
# converting my dataframes to use in the same ggplot structure:
EMA_5.5_Days_ts = EMA_5.5_Days %>% 
  select(ID, PRE_Mean, POST_Mean) %>% 
  pivot_longer(!ID, names_to = "Interval", values_to = "Mean") %>% 
  mutate(ID = as.factor(ID),
         Interval = rep(c(1,2), times = nrow(EMA_5.5_Days)))

save(EMA_5.5_Days_ts, file = "Time Series Dataframes/k20_EMA_5.5_Days_n50_ts.RData")

###

load("Time Series Dataframes/k20_EMA_5.5_Days_n50_ts.RData")

# Repeated measures with box− and violin plots
EMA_5.5_Days_ts$jit = jitter(EMA_5.5_Days_ts$Interval, amount = .09)

Pre_Post_Box_Violin = ggplot(data = EMA_5.5_Days_ts, aes(y = Mean)) +
  geom_point(data = EMA_5.5_Days_ts %>% filter(Interval == "1"), aes(x = jit), color = "dodgerblue", size = 1,
             alpha = .5) +
  geom_point(data = EMA_5.5_Days_ts %>% filter(Interval == "2"), aes(x = jit), color = "darkorange", size = 1,
             alpha = .5) +
  geom_line(aes(x = jit, group = ID), color = "lightgray", alpha = .05) +
  geom_half_boxplot(
    data = EMA_5.5_Days_ts %>% filter(Interval == "1"), aes(x = Interval, y = Mean), position = position_nudge(x = -.25),
    side = "r", outlier.shape = NA, center = TRUE, errorbar.draw = TRUE, width = .1,
    fill = "dodgerblue", alpha = .5) +
  geom_half_boxplot(
    data = EMA_5.5_Days_ts %>% filter(Interval == "2"), aes(x = Interval, y = Mean), position = position_nudge(x = .15),
    side = "r", outlier.shape = NA, center = TRUE, errorbar.draw = TRUE, width = .1,
    fill = "darkorange", alpha = .5) +
  geom_half_violin(
    data = EMA_5.5_Days_ts %>% filter(Interval == "1"), aes(x = Interval, y = Mean), position = position_nudge(x = 1.3),
    side = "r", fill = "dodgerblue", alpha = .5, trim = FALSE) +
  geom_half_violin(
    data = EMA_5.5_Days_ts %>% filter(Interval == "2"), aes(x = Interval, y = Mean), position = position_nudge(x = .3),
    side = "r", fill = "darkorange", alpha = .5, trim = FALSE) +
  scale_x_continuous(breaks = c(1,2), labels = c("PRE", "POST"), limits = c(0, 3)) +
  xlab("Interval") + ylab("PHQ-9 Mean Score") +
  #ggtitle("EMA Data (5+5 Timepoint Random Days): Individual Pre-Post Means") +
  #theme_classic() +
  theme_bw() +
  coord_cartesian(ylim = c(0, 24))

ggsave("Time Series Dataframes/k20_EMA_5.5_Days_n50_Pre-Post_Box_Violin.jpg", plot = Pre_Post_Box_Violin, width = 6, height = 4)
save(Pre_Post_Box_Violin, file = "Time Series Dataframes/k20_EMA_5.5_Days_n50_Pre_Post_Box_Violin.RData")


# Repeated measures with box− and violin plots and means + CIs
score_mean_1 = EMA_5.5_Days_ts %>% filter(Interval == "1") %>% summarise(mean(Mean)) %>% as.numeric()
score_mean_2 = EMA_5.5_Days_ts %>% filter(Interval == "2") %>% summarise(mean(Mean)) %>% as.numeric()
score_median1 = EMA_5.5_Days_ts %>% filter(Interval == "1") %>% summarise(median(Mean)) %>% as.numeric()
score_median2 = EMA_5.5_Days_ts %>% filter(Interval == "2") %>% summarise(median(Mean)) %>% as.numeric()
score_sd_1 = EMA_5.5_Days_ts %>% filter(Interval == "1") %>% summarise(sd(Mean)) %>% as.numeric()
score_sd_2 = EMA_5.5_Days_ts %>% filter(Interval == "2") %>% summarise(sd(Mean)) %>% as.numeric()
score_se_1 = score_sd_1/sqrt(nrow(EMA_5.5_Days))
score_se_2 = score_sd_2/sqrt(nrow(EMA_5.5_Days))
score_ci_1 = EMA_5.5_Days_ts %>% filter(Interval == "1") %>% pull(Mean) %>% CI(., ci = 0.95)
score_ci_2 = EMA_5.5_Days_ts %>% filter(Interval == "2") %>% pull(Mean) %>% CI(., ci = 0.95)
#Create data frame with 2 rows and 7 columns containing the descriptives
group = c("PRE", "POST")
N = c(nrow(EMA_5.5_Days), nrow(EMA_5.5_Days))
score_mean = c(score_mean_1, score_mean_2)
score_median = c(score_median1, score_median2)
sd = c(score_sd_1, score_sd_2)
se = c(score_se_1, score_se_2)
ci = c(as.numeric(score_ci_1[1] - score_ci_1[3]), as.numeric(score_ci_2[1] - score_ci_2[3]))
summary_df = data.frame(group, N, score_mean, score_median, sd, se, ci)

# EMA_5.5_Days_ts$jit = jitter(EMA_5.5_Days_ts$Interval, amount = .09)     #already created above
x_tick_means = c(.87, 2.13)

Pre_Post_Box_Violin_Mean_CI = ggplot(data = EMA_5.5_Days_ts, aes(y = Mean)) +
  geom_point(data = EMA_5.5_Days_ts %>% filter(Interval == "1"), aes(x = jit), color = "dodgerblue", size = 1,
             alpha = .6) +
  geom_point(data = EMA_5.5_Days_ts %>% filter(Interval == "2"), aes(x = jit), color = "darkorange", size = 1,
             alpha = .6) +
  geom_line(aes(x = jit, group = ID), color = "lightgray", alpha = .05) +
  geom_half_boxplot(
    data = EMA_5.5_Days_ts %>% filter(Interval == "1"), aes(x = Interval, y = Mean), position = position_nudge(x = -.28),
    side = "r", outlier.shape = NA, center = TRUE, errorbar.draw = FALSE, width = .2,
    fill = "dodgerblue") +
  geom_half_boxplot(
    data = EMA_5.5_Days_ts %>% filter(Interval == "2"), aes(x = Interval, y = Mean), position = position_nudge(x = .18),
    side = "r", outlier.shape = NA, center = TRUE, errorbar.draw = FALSE, width = .2,
    fill = "darkorange") +
  geom_half_violin(
    data = EMA_5.5_Days_ts %>% filter(Interval == "1"), aes(x = Interval, y = Mean), position = position_nudge(x = -.3),
    side = "l", fill = "dodgerblue") +
  geom_half_violin(
    data = EMA_5.5_Days_ts %>% filter(Interval == "2"),aes(x = Interval, y = Mean), position = position_nudge(x = .3),
    side = "r", fill = "darkorange") +
  geom_point(data = EMA_5.5_Days_ts %>% filter(Interval == "1"), aes(x = Interval, y = score_mean[1]),
             position = position_nudge(x = -.13), color = "dodgerblue", alpha = .6, size = 1.5) +
  geom_errorbar(data = EMA_5.5_Days_ts %>% filter(Interval == "1"), aes(x = Interval, y = score_mean[1],
                                                 ymin = score_mean[1]-ci[1], ymax = score_mean[1]+ci[1]),
                position = position_nudge(-.13), color = "dodgerblue", width = 0.05, size = 0.4, alpha = .6) +
  geom_point(data = EMA_5.5_Days_ts %>% filter(Interval == "2"), aes(x = Interval, y = score_mean[2]),
             position = position_nudge(x = .13), color = "darkorange", alpha = .6, size = 1.5)+
  geom_errorbar(data = EMA_5.5_Days_ts %>% filter(Interval == "2"), aes(x = Interval, y = score_mean[2],
                                                 ymin = score_mean[2]-ci[2], ymax = score_mean[2]+ci[2]), 
                position = position_nudge(.13), color = "darkorange", width = 0.05, size = 0.4, alpha = .6) +
  geom_line(data = summary_df, aes(x = x_tick_means, y = score_mean), color = "gray", size = 1) +
  scale_x_continuous(breaks = c(1,2), labels = c("PRE", "POST"), limits = c(0, 3)) +
  xlab("Interval") + ylab("PHQ-9 Mean Score") +
  #ggtitle("EMA Data (5+5 Timepoint Random Days): Individual Pre-Post Means") +
  #theme_classic() +
  theme_bw() +
  coord_cartesian(ylim = c(0, 24))

ggsave("Time Series Dataframes/k20_EMA_5.5_Days_n50_Pre-Post_Box_Violin_Mean+CI.jpg", plot = Pre_Post_Box_Violin_Mean_CI, width = 6, height = 4)
save(Pre_Post_Box_Violin_Mean_CI, file = "Time Series Dataframes/k20_EMA_5.5_Days_n50_Pre_Post_Box_Violin_Mean_CI.RData")
#knitr::include_graphics("Time Series Dataframes/k20_EMA_5.5_Days_n50_Pre-Post_Box_Violin.jpg")
knitr::include_graphics("Time Series Dataframes/k20_EMA_5.5_Days_n50_Pre-Post_Box_Violin_Mean+CI.jpg")


1.3 Deskriptive Statistiken der Datensets

tibble(Descriptives = c("mean_PRE_Mean","mean_POST_Mean","mean_MeanDiff","mean_ind.pretestSD","mean_ind.posttestSD"),
       EMA_5.5 = round(c(mean(EMA_5.5$PRE_Mean),mean(EMA_5.5$POST_Mean),mean(EMA_5.5$MeanDiff),
                        mean(EMA_5.5$ind.pretestSD),mean(EMA_5.5$ind.posttestSD)), digits = 3),
       EMA_30.30 = round(c(mean(EMA_30.30$PRE_Mean),mean(EMA_30.30$POST_Mean),mean(EMA_30.30$MeanDiff),
                          mean(EMA_30.30$ind.pretestSD),mean(EMA_30.30$ind.posttestSD)), digits = 3),
       EMA_5.5_Window = round(c(mean(EMA_5.5_Window$PRE_Mean),mean(EMA_5.5_Window$POST_Mean),
                             mean(EMA_5.5_Window$MeanDiff),mean(EMA_5.5_Window$ind.pretestSD),
                             mean(EMA_5.5_Window$ind.posttestSD)), digits = 3),
       EMA_5.5_Days = round(c(mean(EMA_5.5_Days$PRE_Mean),mean(EMA_5.5_Days$POST_Mean),mean(EMA_5.5_Days$MeanDiff),
                           mean(EMA_5.5_Days$ind.pretestSD),mean(EMA_5.5_Days$ind.posttestSD)), digits = 3)) %>%
  kable() %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = FALSE)
Descriptives EMA_5.5 EMA_30.30 EMA_5.5_Window EMA_5.5_Days
mean_PRE_Mean 10.464 10.464 10.492 10.200
mean_POST_Mean 7.608 7.608 7.684 7.320
mean_MeanDiff 2.856 2.856 2.808 2.880
mean_ind.pretestSD 2.481 2.257 2.256 2.300
mean_ind.posttestSD 3.726 3.390 3.403 3.362

Boxplots der Pre- und Post-Mittelwerte

# Boxplots zum Vergleich
temp = tibble(Scores = c(EMA_5.5$PRE_Mean, EMA_30.30$PRE_Mean, EMA_5.5_Window$PRE_Mean, EMA_5.5_Days$PRE_Mean),
              Datasets = rep(c("EMA_5.5", "EMA_30.30", "EMA_5.5_Window", "EMA_5.5_Days"), each =
                               length(EMA_5.5$PRE_Mean)))

ggplot(temp, aes(x = Datasets, y = Scores)) + 
  geom_boxplot() + 
  ylim(0, 27) +
  ggtitle("PHQ-9 PRE-Mean") +
  xlab("Dataset") +
  ylab("PHQ-9 Scores")

temp = tibble(Scores = c(EMA_5.5$POST_Mean, EMA_30.30$POST_Mean, EMA_5.5_Window$POST_Mean,
                         EMA_5.5_Days$POST_Mean), Datasets = rep(c("EMA_5.5", "EMA_30.30", "EMA_5.5_Window",
                         "EMA_5.5_Days"), each = length(EMA_5.5$POST_Mean)))

ggplot(temp, aes(x = Datasets, y = Scores)) + 
  geom_boxplot() + 
  ylim(0, 27) +
  ggtitle("PHQ-9 POST-Mean") +
  xlab("Dataset") +
  ylab("PHQ-9 Scores")

Prozentuale Überlappung der Pre-Mittelwerte

# Overlap-Plots zum Vergleich
final.plot(list(EMA_5.5_PRE_Mean = EMA_5.5$PRE_Mean, EMA_30.30_PRE_Mean = EMA_30.30$PRE_Mean), 
           overlap(list(EMA_5.5_PRE_Mean = EMA_5.5$PRE_Mean, EMA_30.30_PRE_Mean = EMA_30.30$PRE_Mean))$OV)

final.plot(list(EMA_5.5_PRE_Mean = EMA_5.5$PRE_Mean, EMA_5.5_Window_PRE_Mean = EMA_5.5_Window$PRE_Mean), 
           overlap(list(EMA_5.5_PRE_Mean = EMA_5.5$PRE_Mean, EMA_5.5_Window_PRE_Mean =
                          EMA_5.5_Window$PRE_Mean))$OV)

final.plot(list(EMA_5.5_PRE_Mean = EMA_5.5$PRE_Mean, EMA_5.5_Days_PRE_Mean = EMA_5.5_Days$PRE_Mean), 
           overlap(list(EMA_5.5_PRE_Mean = EMA_5.5$PRE_Mean, EMA_5.5_Days_PRE_Mean =
                          EMA_5.5_Days$PRE_Mean))$OV)

Prozentuale Überlappung der Post-Mittelwerte

# Overlap-Plots zum Vergleich
final.plot(list(EMA_5.5_POST_Mean = EMA_5.5$POST_Mean, EMA_30MZP_POST_Mean = EMA_30.30$POST_Mean), 
           overlap(list(EMA_5.5_POST_Mean = EMA_5.5$POST_Mean, EMA_30MZP_POST_Mean =
                          EMA_30.30$POST_Mean))$OV)

final.plot(list(EMA_5.5_POST_Mean = EMA_5.5$POST_Mean, EMA_Window_POST_Mean = EMA_5.5_Window$POST_Mean), 
           overlap(list(EMA_5.5_POST_Mean = EMA_5.5$POST_Mean, EMA_Window_POST_Mean =
                          EMA_5.5_Window$POST_Mean))$OV)

final.plot(list(EMA_5.5_POST_Mean = EMA_5.5$POST_Mean, EMA_Days_POST_Mean = EMA_5.5_Days$POST_Mean), 
           overlap(list(EMA_5.5_POST_Mean = EMA_5.5$POST_Mean, EMA_Days_POST_Mean = EMA_5.5_Days$POST_Mean))$OV)


1.4 Reliabilitäten und Inter-Item-Korrelationen

1.4.1 EMA_5.5 (je 5 MZP)

# Korrelationsmatrix von PRE- und POST-MZP:
EMA_5.5_KorMat = cor(EMA_5.5[, c(pre_5mzp, post_5mzp)]) %>% 
  round(., digits = 2)

# durchschnittliche paarweise Korrelation zwischen aufeinanderfolgenden MZP (beachte: ohne Fisher-Z-Transformation):
pre_inter_item_rtt = 0L
for (i in 1:4) {
  pre_inter_item_rtt = pre_inter_item_rtt + FisherZ(EMA_5.5_KorMat[i,i+1])
}
pre_inter_item_rtt = FisherZInv(pre_inter_item_rtt / 4)

post_inter_item_rtt = 0L
for (i in 5:9) {
  post_inter_item_rtt = post_inter_item_rtt + FisherZ(EMA_5.5_KorMat[i,i+1])
}
post_inter_item_rtt = FisherZInv(post_inter_item_rtt / 4)


for (i in 1:9) {
  EMA_5.5_KorMat[i, i+1] = cell_spec(EMA_5.5_KorMat[i, i+1], "html", bold = TRUE)
}

rownames(EMA_5.5_KorMat) = cell_spec(rownames(EMA_5.5_KorMat), "html", bold = TRUE)

EMA_5.5_KorMat %>%
  kable(., format = "html", escape = FALSE) %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"),
                full_width = FALSE, fixed_thead = T)
PRE1_1 PRE1_2 PRE1_3 PRE1_4 PRE1_5 POST1_1 POST1_2 POST1_3 POST1_4 POST1_5
PRE1_1 1 0.44 0.42 -0.09 -0.01 0.1 -0.01 -0.03 -0.18 0
PRE1_2 0.44 1 0.59 0.17 0.31 -0.2 -0.06 -0.07 -0.15 0.07
PRE1_3 0.42 0.59 1 0.29 0.16 -0.35 -0.17 -0.16 -0.27 0.14
PRE1_4 -0.09 0.17 0.29 1 0.4 -0.18 -0.06 -0.1 0.22 0.29
PRE1_5 -0.01 0.31 0.16 0.4 1 -0.2 -0.11 -0.06 0.03 0.22
POST1_1 0.1 -0.2 -0.35 -0.18 -0.2 1 0.54 0.26 0.07 -0.11
POST1_2 -0.01 -0.06 -0.17 -0.06 -0.11 0.54 1 0.37 0.18 -0.16
POST1_3 -0.03 -0.07 -0.16 -0.1 -0.06 0.26 0.37 1 0.47 -0.09
POST1_4 -0.18 -0.15 -0.27 0.22 0.03 0.07 0.18 0.47 1 0.16
POST1_5 0 0.07 0.14 0.29 0.22 -0.11 -0.16 -0.09 0.16 1
# mittleres Cronbach´s Alpha zwischen Pre-MZP und Post-MZP:
PRE_alpha = CronbachAlpha(EMA_5.5[pre_5mzp])
POST_alpha = CronbachAlpha(EMA_5.5[post_5mzp])
EMA_5.5_Alpha = FisherZInv(mean(c(FisherZ(PRE_alpha), FisherZ(POST_alpha))))

Korrelation zwischen den Pre- und Post-Intervall-Mittelwerten = -0.154.
Durchschnittliche paarweise Korrelation zwischen aufeinanderfolgenden Pre-MZP (Fisher-Z-transformiert): r = 0.44.
Durchschnittliche paarweise Korrelation zwischen aufeinanderfolgenden Post-MZP (Fisher-Z-transformiert): r = 0.35.
Mittleres Cronbach´s Alpha zwischen Pre-MZP und Post-MZP = 0.591.


1.4.2 EMA_30.30 (je 30 MZP)

# Korrelationsmatrix von PRE- und POST-MZP:
EMA_30.30_KorMat = cor(EMA_30.30[, c(pre_30mzp, post_30mzp)]) %>% 
  round(., digits = 2)


# durchschnittliche paarweise Korrelation zwischen aufeinanderfolgenden MZP (beachte: ohne Fisher-Z-Transformation):
pre_inter_item_rtt = 0L
for (i in 1:29) {
  pre_inter_item_rtt = pre_inter_item_rtt + FisherZ(EMA_30.30_KorMat[i,i+1])
}
pre_inter_item_rtt = FisherZInv(pre_inter_item_rtt / 29)

post_inter_item_rtt = 0L
for (i in 31:59) {
  post_inter_item_rtt = post_inter_item_rtt + FisherZ(EMA_30.30_KorMat[i,i+1])
}
post_inter_item_rtt = FisherZInv(post_inter_item_rtt / 29)


for (i in 1:59) {
  EMA_30.30_KorMat[i, i+1] = cell_spec(EMA_30.30_KorMat[i, i+1], "html", bold = TRUE)
}

rownames(EMA_30.30_KorMat) = cell_spec(rownames(EMA_30.30_KorMat), "html", bold = TRUE)

EMA_30.30_KorMat %>%
  kable(., format = "html", escape = FALSE) %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"),
                full_width = FALSE, fixed_thead = T) %>%
  scroll_box(height = "800px")
PRE1_1 PRE1_2 PRE1_3 PRE1_4 PRE1_5 PRE1_6 PRE1_7 PRE1_8 PRE1_9 PRE1_10 PRE1_11 PRE1_12 PRE1_13 PRE1_14 PRE1_15 PRE1_16 PRE1_17 PRE1_18 PRE1_19 PRE1_20 PRE1_21 PRE1_22 PRE1_23 PRE1_24 PRE1_25 PRE1_26 PRE1_27 PRE1_28 PRE1_29 PRE1_30 POST1_1 POST1_2 POST1_3 POST1_4 POST1_5 POST1_6 POST1_7 POST1_8 POST1_9 POST1_10 POST1_11 POST1_12 POST1_13 POST1_14 POST1_15 POST1_16 POST1_17 POST1_18 POST1_19 POST1_20 POST1_21 POST1_22 POST1_23 POST1_24 POST1_25 POST1_26 POST1_27 POST1_28 POST1_29 POST1_30
PRE1_1 1 0.44 0.42 -0.09 -0.01 0.34 0.3 0.42 0.39 0.31 0.37 0.37 0.35 0.19 0.48 0.53 0.3 0.31 0.37 0.23 0.34 0.34 0.4 0.34 0.32 0.39 0.42 0.37 0.18 0.38 0.1 -0.01 -0.03 -0.18 0 0.12 0.13 -0.05 -0.19 -0.11 -0.01 0.08 -0.13 -0.08 0.04 -0.01 -0.19 -0.1 0 0.2 0 -0.05 -0.08 -0.07 0.11 0.02 -0.01 -0.09 0.01 -0.02
PRE1_2 0.44 1 0.59 0.17 0.31 0.46 0.58 0.63 0.5 0.41 0.65 0.49 0.39 0.49 0.57 0.62 0.57 0.43 0.73 0.23 0.54 0.49 0.62 0.49 0.42 0.58 0.54 0.58 0.44 0.42 -0.2 -0.06 -0.07 -0.15 0.07 -0.07 -0.11 0.05 -0.27 -0.03 -0.04 -0.01 -0.3 -0.04 -0.01 -0.21 -0.13 -0.24 0.06 0.08 0.08 -0.07 -0.22 -0.17 -0.04 -0.06 -0.05 -0.11 -0.04 -0.15
PRE1_3 0.42 0.59 1 0.29 0.16 0.69 0.62 0.43 0.43 0.33 0.62 0.61 0.5 0.4 0.38 0.49 0.53 0.68 0.51 0.28 0.57 0.39 0.43 0.67 0.43 0.39 0.56 0.46 0.38 0.69 -0.35 -0.17 -0.16 -0.27 0.14 -0.09 -0.18 -0.12 -0.34 -0.11 -0.08 -0.07 -0.32 -0.18 -0.18 -0.18 -0.22 -0.07 -0.22 -0.13 -0.02 -0.21 -0.29 -0.11 -0.2 -0.16 -0.3 -0.29 0.01 -0.08
PRE1_4 -0.09 0.17 0.29 1 0.4 0.18 0.49 0.27 0.38 0.45 0.31 0.41 0.43 0.46 0.16 0.11 0.32 0.37 0.46 0.5 0.38 0.44 0.3 0.42 0.23 0.18 0.18 0.53 0.51 0.37 -0.18 -0.06 -0.1 0.22 0.29 -0.01 0.06 -0.11 0 0.19 0.14 0.05 -0.04 -0.14 0.07 0.04 0.16 0.14 -0.1 -0.12 0.2 -0.06 0.15 -0.23 0.02 -0.12 -0.12 0.08 0.04 0.21
PRE1_5 -0.01 0.31 0.16 0.4 1 0.28 0.37 0.55 0.38 0.31 0.21 0.34 0.41 0.58 0.33 0.28 0.61 0.4 0.35 0.26 0.39 0.57 0.48 0.25 0.15 0.46 0.38 0.39 0.45 0.21 -0.2 -0.11 -0.06 0.03 0.22 0.05 -0.1 -0.08 -0.08 0.03 -0.14 -0.04 -0.26 0.19 0.09 -0.24 -0.1 -0.13 0.14 0.14 0.09 -0.12 0.12 -0.22 -0.05 0.04 -0.2 0.04 -0.06 0
PRE1_6 0.34 0.46 0.69 0.18 0.28 1 0.53 0.31 0.08 0.02 0.38 0.32 0.53 0.53 0.2 0.45 0.36 0.56 0.35 0.25 0.48 0.33 0.28 0.48 0.41 0.36 0.35 0.18 0.49 0.6 -0.36 -0.11 -0.05 -0.22 0.03 -0.16 -0.25 0 -0.22 -0.11 -0.1 -0.14 -0.21 -0.18 -0.1 -0.16 -0.12 -0.15 -0.19 -0.09 0.05 -0.08 -0.26 -0.29 -0.16 -0.09 -0.32 -0.27 0.09 -0.11
PRE1_7 0.3 0.58 0.62 0.49 0.37 0.53 1 0.46 0.18 0.14 0.43 0.4 0.33 0.63 0.57 0.57 0.48 0.57 0.52 0.23 0.54 0.5 0.34 0.54 0.47 0.45 0.48 0.57 0.37 0.51 -0.25 -0.08 0.01 0.03 0.24 0.13 -0.08 -0.1 -0.16 0.1 -0.13 0.01 -0.07 0.02 0.07 -0.07 -0.04 -0.06 0.01 0.05 0.16 0.04 -0.04 -0.18 -0.1 -0.01 -0.1 0 -0.02 0.02
PRE1_8 0.42 0.63 0.43 0.27 0.55 0.31 0.46 1 0.34 0.18 0.41 0.51 0.59 0.48 0.36 0.51 0.62 0.41 0.49 0.32 0.37 0.54 0.65 0.41 0.35 0.59 0.57 0.64 0.28 0.25 -0.18 -0.23 -0.28 -0.29 0.12 -0.08 -0.18 -0.14 -0.38 -0.11 -0.17 -0.27 -0.36 -0.04 -0.04 -0.18 -0.28 -0.24 -0.14 -0.03 -0.16 -0.22 -0.11 -0.37 -0.02 -0.1 -0.22 -0.22 -0.07 -0.25
PRE1_9 0.39 0.5 0.43 0.38 0.38 0.08 0.18 0.34 1 0.56 0.59 0.58 0.36 0.23 0.39 0.23 0.47 0.23 0.67 0.49 0.42 0.57 0.44 0.42 0.2 0.22 0.39 0.6 0.48 0.41 -0.06 -0.05 -0.1 0.07 0.05 0.01 0.08 -0.16 -0.07 0.06 0.12 0.15 -0.31 -0.11 0.04 -0.25 -0.11 0.01 0.11 0.14 -0.04 -0.25 0.03 0.03 0.16 -0.16 -0.06 0.05 -0.1 0.15
PRE1_10 0.31 0.41 0.33 0.45 0.31 0.02 0.14 0.18 0.56 1 0.42 0.43 0.29 0.26 0.42 0.27 0.43 0.45 0.44 0.23 0.47 0.29 0.57 0.32 0.11 0.43 0.33 0.36 0.39 0.31 0.01 0.08 0 0.05 0.27 0.08 0.22 0.12 -0.06 0.04 0.16 0.28 -0.14 0.06 0.04 0.04 0.07 0.04 0.12 0.11 0.37 -0.01 0.05 0.01 -0.04 0.08 0.04 0.08 0.05 0.14
PRE1_11 0.37 0.65 0.62 0.31 0.21 0.38 0.43 0.41 0.59 0.42 1 0.47 0.36 0.15 0.29 0.42 0.49 0.35 0.63 0.33 0.54 0.48 0.4 0.37 0.41 0.33 0.39 0.52 0.57 0.41 -0.09 -0.08 -0.08 -0.01 0.18 -0.18 0.07 0.14 -0.24 0.11 0.25 0.14 -0.25 -0.22 -0.03 -0.07 -0.08 0 0.1 -0.07 0.15 -0.18 -0.1 0.02 0.01 -0.08 -0.01 -0.14 0 0.12
PRE1_12 0.37 0.49 0.61 0.41 0.34 0.32 0.4 0.51 0.58 0.43 0.47 1 0.44 0.17 0.24 0.38 0.53 0.41 0.53 0.39 0.35 0.4 0.54 0.49 0.47 0.41 0.59 0.53 0.31 0.39 -0.2 -0.28 -0.23 -0.26 0.07 -0.19 -0.12 -0.26 -0.4 0.06 -0.09 -0.01 -0.31 -0.32 -0.2 -0.18 -0.18 -0.12 -0.19 -0.25 -0.11 -0.33 -0.28 -0.11 -0.08 -0.26 -0.33 -0.27 -0.07 -0.01
PRE1_13 0.35 0.39 0.5 0.43 0.41 0.53 0.33 0.59 0.36 0.29 0.36 0.44 1 0.33 -0.03 0.26 0.47 0.49 0.42 0.45 0.25 0.37 0.64 0.59 0.23 0.39 0.26 0.44 0.53 0.47 -0.29 -0.11 -0.12 -0.01 -0.02 -0.18 -0.22 -0.01 -0.18 0.02 0.05 -0.18 -0.23 -0.14 -0.07 -0.12 -0.05 -0.2 -0.24 0.04 -0.01 -0.12 -0.2 -0.23 0.01 -0.22 -0.2 -0.13 0.14 -0.14
PRE1_14 0.19 0.49 0.4 0.46 0.58 0.53 0.63 0.48 0.23 0.26 0.15 0.17 0.33 1 0.43 0.46 0.51 0.55 0.43 0.21 0.56 0.58 0.31 0.45 0.2 0.52 0.35 0.43 0.37 0.48 -0.3 -0.02 -0.07 -0.03 0.29 0.28 -0.13 -0.13 -0.11 -0.12 -0.23 -0.03 -0.19 0.14 0.14 -0.17 -0.02 -0.07 -0.05 0.15 0.2 0.04 0.01 -0.39 -0.06 0.04 -0.23 0.15 -0.06 -0.09
PRE1_15 0.48 0.57 0.38 0.16 0.33 0.2 0.57 0.36 0.39 0.42 0.29 0.24 -0.03 0.43 1 0.53 0.38 0.41 0.48 0.15 0.54 0.4 0.39 0.3 0.29 0.4 0.55 0.45 0.22 0.33 0.02 0.05 0.07 -0.06 0.18 0.2 0.17 -0.05 0 -0.08 -0.11 0.09 -0.11 0.24 0.15 -0.1 -0.15 -0.02 0.25 0.25 0.11 0.04 0.21 -0.07 -0.06 0.2 0.07 -0.03 -0.07 0.06
PRE1_16 0.53 0.62 0.49 0.11 0.28 0.45 0.57 0.51 0.23 0.27 0.42 0.38 0.26 0.46 0.53 1 0.57 0.37 0.32 -0.17 0.58 0.39 0.44 0.34 0.26 0.49 0.67 0.33 0.21 0.36 -0.08 0 -0.03 -0.21 0.09 0.15 -0.06 -0.05 -0.1 -0.18 -0.26 -0.01 -0.11 0 0.15 -0.12 -0.14 -0.18 0.06 0.15 0.03 -0.02 -0.03 -0.1 -0.11 0.13 -0.24 -0.09 0.04 -0.06
PRE1_17 0.3 0.57 0.53 0.32 0.61 0.36 0.48 0.62 0.47 0.43 0.49 0.53 0.47 0.51 0.38 0.57 1 0.48 0.35 0 0.47 0.64 0.66 0.26 0.29 0.61 0.6 0.51 0.3 0.34 -0.34 -0.13 -0.4 -0.22 0.26 -0.06 -0.16 -0.22 -0.25 -0.17 -0.18 -0.13 -0.53 -0.09 0.06 -0.26 -0.26 -0.4 -0.1 0.13 -0.01 -0.31 -0.09 -0.28 -0.17 -0.16 -0.39 -0.08 -0.14 -0.1
PRE1_18 0.31 0.43 0.68 0.37 0.4 0.56 0.57 0.41 0.23 0.45 0.35 0.41 0.49 0.55 0.41 0.37 0.48 1 0.28 0.1 0.52 0.33 0.51 0.58 0.25 0.53 0.37 0.3 0.36 0.64 -0.24 -0.11 0.01 -0.12 0.16 0.05 -0.11 0.03 -0.19 -0.13 -0.05 0.09 -0.19 -0.02 -0.15 -0.12 -0.08 -0.02 -0.13 0.03 0.11 0 -0.13 -0.14 -0.2 -0.02 -0.17 -0.1 0.04 -0.07
PRE1_19 0.37 0.73 0.51 0.46 0.35 0.35 0.52 0.49 0.67 0.44 0.63 0.53 0.42 0.43 0.48 0.32 0.35 0.28 1 0.51 0.48 0.49 0.44 0.6 0.46 0.32 0.43 0.66 0.56 0.5 -0.07 0.03 0 0.04 0.1 -0.07 0.04 0.02 -0.15 0.26 0.12 0.02 -0.17 0 0.1 -0.1 0.02 0.04 0.11 -0.01 0.14 0 -0.02 -0.15 0.11 -0.04 0.02 0.05 -0.03 0.07
PRE1_20 0.23 0.23 0.28 0.5 0.26 0.25 0.23 0.32 0.49 0.23 0.33 0.39 0.45 0.21 0.15 -0.17 0 0.1 0.51 1 0.21 0.39 0.23 0.39 0.3 0.12 0.06 0.55 0.54 0.24 -0.13 -0.19 -0.02 0.13 0.12 -0.09 0.05 -0.08 -0.2 0.19 0.2 0.01 -0.1 -0.13 -0.13 -0.04 -0.03 0.11 -0.05 -0.12 0.07 -0.18 -0.06 -0.15 0.18 -0.18 0.09 -0.15 0.02 0.08
PRE1_21 0.34 0.54 0.57 0.38 0.39 0.48 0.54 0.37 0.42 0.47 0.54 0.35 0.25 0.56 0.54 0.58 0.47 0.52 0.48 0.21 1 0.46 0.23 0.35 0.11 0.52 0.46 0.3 0.52 0.47 -0.18 0.02 0.03 -0.1 0.09 0.13 -0.06 -0.08 -0.05 -0.1 -0.1 0.12 -0.14 0.01 -0.03 -0.29 -0.12 0.01 0.16 0.09 0.13 -0.03 0.04 -0.08 -0.22 -0.02 -0.21 -0.04 -0.04 0.14
PRE1_22 0.34 0.49 0.39 0.44 0.57 0.33 0.5 0.54 0.57 0.29 0.48 0.4 0.37 0.58 0.4 0.39 0.64 0.33 0.49 0.39 0.46 1 0.39 0.19 0.13 0.39 0.5 0.64 0.44 0.27 -0.15 -0.11 -0.22 -0.11 0.16 0.16 -0.1 -0.1 -0.26 -0.18 -0.1 0.03 -0.36 -0.13 0.1 -0.16 -0.11 -0.22 -0.05 0.06 0.08 -0.17 0.05 -0.3 -0.11 -0.09 -0.19 -0.04 -0.21 0.05
PRE1_23 0.4 0.62 0.43 0.3 0.48 0.28 0.34 0.65 0.44 0.57 0.4 0.54 0.64 0.31 0.39 0.44 0.66 0.51 0.44 0.23 0.23 0.39 1 0.38 0.21 0.56 0.47 0.54 0.29 0.38 -0.11 -0.02 -0.08 -0.06 0.15 0.02 0.02 0.08 -0.26 -0.01 -0.04 -0.01 -0.24 0.03 0.12 -0.06 -0.09 -0.17 0.02 0.15 0.06 -0.04 -0.12 -0.09 0.07 -0.06 -0.03 -0.04 0.18 -0.16
PRE1_24 0.34 0.49 0.67 0.42 0.25 0.48 0.54 0.41 0.42 0.32 0.37 0.49 0.59 0.45 0.3 0.34 0.26 0.58 0.6 0.39 0.35 0.19 0.38 1 0.28 0.28 0.26 0.43 0.44 0.76 -0.19 -0.1 -0.06 0 0.09 -0.08 -0.12 -0.07 -0.13 0.12 0.02 -0.16 -0.11 0.02 -0.06 -0.17 0 0.14 -0.18 -0.04 0.02 -0.04 -0.14 -0.17 0.04 -0.05 -0.16 -0.08 0.07 -0.06
PRE1_25 0.32 0.42 0.43 0.23 0.15 0.41 0.47 0.35 0.2 0.11 0.41 0.47 0.23 0.2 0.29 0.26 0.29 0.25 0.46 0.3 0.11 0.13 0.21 0.28 1 0.25 0.41 0.45 0.28 0.18 -0.25 -0.25 -0.11 -0.08 0.24 -0.33 0.05 -0.16 -0.21 0.2 0.1 0 -0.24 -0.21 -0.14 0.1 -0.17 -0.19 -0.1 -0.15 0.06 -0.27 -0.19 -0.18 0.1 -0.06 -0.08 -0.21 -0.09 -0.06
PRE1_26 0.39 0.58 0.39 0.18 0.46 0.36 0.45 0.59 0.22 0.43 0.33 0.41 0.39 0.52 0.4 0.49 0.61 0.53 0.32 0.12 0.52 0.39 0.56 0.28 0.25 1 0.35 0.3 0.19 0.18 -0.29 -0.07 -0.18 -0.11 0.03 0.02 -0.16 -0.05 -0.26 -0.2 -0.16 -0.05 -0.26 -0.04 -0.11 -0.27 -0.14 -0.2 -0.1 0.07 0.09 -0.08 -0.09 -0.38 -0.2 -0.04 -0.16 -0.01 -0.18 -0.25
PRE1_27 0.42 0.54 0.56 0.18 0.38 0.35 0.48 0.57 0.39 0.33 0.39 0.59 0.26 0.35 0.55 0.67 0.6 0.37 0.43 0.06 0.46 0.5 0.47 0.26 0.41 0.35 1 0.41 0.14 0.23 -0.09 -0.06 -0.18 -0.34 0.09 0.09 -0.06 -0.11 -0.37 -0.14 -0.22 -0.05 -0.3 0 0 -0.12 -0.27 -0.28 0.04 0.03 0.01 -0.14 -0.1 -0.16 -0.19 0.05 -0.28 -0.2 -0.03 -0.11
PRE1_28 0.37 0.58 0.46 0.53 0.39 0.18 0.57 0.64 0.6 0.36 0.52 0.53 0.44 0.43 0.45 0.33 0.51 0.3 0.66 0.55 0.3 0.64 0.54 0.43 0.45 0.3 0.41 1 0.34 0.29 -0.18 -0.1 -0.19 -0.02 0.31 -0.05 0.08 -0.07 -0.25 0.07 0.03 0.07 -0.21 -0.11 -0.02 -0.03 -0.1 -0.1 -0.06 0.05 0.03 -0.22 -0.03 -0.14 0.14 -0.22 -0.02 -0.02 0.01 0.01
PRE1_29 0.18 0.44 0.38 0.51 0.45 0.49 0.37 0.28 0.48 0.39 0.57 0.31 0.53 0.37 0.22 0.21 0.3 0.36 0.56 0.54 0.52 0.44 0.29 0.44 0.28 0.19 0.14 0.34 1 0.37 -0.22 -0.22 0.14 0.2 0.1 -0.18 -0.04 -0.02 0.04 0.14 0.12 0.02 -0.16 -0.12 0.06 -0.15 0.09 0.02 0.04 -0.09 0.14 -0.1 -0.05 -0.11 0.05 -0.05 -0.09 -0.17 0.05 0.19
PRE1_30 0.38 0.42 0.69 0.37 0.21 0.6 0.51 0.25 0.41 0.31 0.41 0.39 0.47 0.48 0.33 0.36 0.34 0.64 0.5 0.24 0.47 0.27 0.38 0.76 0.18 0.18 0.23 0.29 0.37 1 -0.06 0.03 0.01 -0.08 0.16 0.09 -0.06 -0.04 -0.05 0.11 0.07 0 -0.14 0.03 0.1 -0.07 -0.05 0.14 -0.02 0.09 0.08 0.03 -0.06 -0.02 0.02 -0.02 -0.13 0.01 0.09 0.1
POST1_1 0.1 -0.2 -0.35 -0.18 -0.2 -0.36 -0.25 -0.18 -0.06 0.01 -0.09 -0.2 -0.29 -0.3 0.02 -0.08 -0.34 -0.24 -0.07 -0.13 -0.18 -0.15 -0.11 -0.19 -0.25 -0.29 -0.09 -0.18 -0.22 -0.06 1 0.54 0.26 0.07 -0.11 0.34 0.51 0.39 0.4 0.24 0.37 0.24 0.52 0.38 0.37 0.48 0.09 0.45 0.54 0.35 0.14 0.51 0.63 0.51 0.06 0.42 0.39 0.46 0.31 0.29
POST1_2 -0.01 -0.06 -0.17 -0.06 -0.11 -0.11 -0.08 -0.23 -0.05 0.08 -0.08 -0.28 -0.11 -0.02 0.05 0 -0.13 -0.11 0.03 -0.19 0.02 -0.11 -0.02 -0.1 -0.25 -0.07 -0.06 -0.1 -0.22 0.03 0.54 1 0.37 0.18 -0.16 0.3 0.45 0.53 0.52 0.28 0.46 0.37 0.48 0.49 0.29 0.36 0.29 0.3 0.57 0.55 0.26 0.61 0.58 0.46 0.14 0.4 0.44 0.66 0.4 0.18
POST1_3 -0.03 -0.07 -0.16 -0.1 -0.06 -0.05 0.01 -0.28 -0.1 0 -0.08 -0.23 -0.12 -0.07 0.07 -0.03 -0.4 0.01 0 -0.02 0.03 -0.22 -0.08 -0.06 -0.11 -0.18 -0.18 -0.19 0.14 0.01 0.26 0.37 1 0.47 -0.09 0.35 0.35 0.43 0.44 0.45 0.17 0.59 0.62 0.4 0.25 0.46 0.42 0.26 0.53 0.32 0.32 0.57 0.26 0.49 0.38 0.5 0.55 0.27 0.43 0.3
POST1_4 -0.18 -0.15 -0.27 0.22 0.03 -0.22 0.03 -0.29 0.07 0.05 -0.01 -0.26 -0.01 -0.03 -0.06 -0.21 -0.22 -0.12 0.04 0.13 -0.1 -0.11 -0.06 0 -0.08 -0.11 -0.34 -0.02 0.2 -0.08 0.07 0.18 0.47 1 0.16 0.32 0.47 0.2 0.42 0.39 0.18 0.42 0.4 0.41 0.36 0.24 0.53 0.26 0.41 0.3 0.34 0.43 0.31 0.23 0.45 0.17 0.42 0.43 0.4 0.36
POST1_5 0 0.07 0.14 0.29 0.22 0.03 0.24 0.12 0.05 0.27 0.18 0.07 -0.02 0.29 0.18 0.09 0.26 0.16 0.1 0.12 0.09 0.16 0.15 0.09 0.24 0.03 0.09 0.31 0.1 0.16 -0.11 -0.16 -0.09 0.16 1 0.2 0.22 0.1 -0.02 0.17 0.2 0.23 -0.06 0.07 0.23 0.31 0.33 0.05 0.01 -0.05 0.48 0.01 0.08 -0.09 0.18 0.11 0.06 0.05 0.16 0.28
POST1_6 0.12 -0.07 -0.09 -0.01 0.05 -0.16 0.13 -0.08 0.01 0.08 -0.18 -0.19 -0.18 0.28 0.2 0.15 -0.06 0.05 -0.07 -0.09 0.13 0.16 0.02 -0.08 -0.33 0.02 0.09 -0.05 -0.18 0.09 0.34 0.3 0.35 0.32 0.2 1 0.29 0.03 0.13 0 -0.06 0.45 0.33 0.46 0.35 0.14 0.18 0.35 0.41 0.43 0.26 0.4 0.28 0.3 0.27 0.32 0.23 0.56 0.22 0.16
POST1_7 0.13 -0.11 -0.18 0.06 -0.1 -0.25 -0.08 -0.18 0.08 0.22 0.07 -0.12 -0.22 -0.13 0.17 -0.06 -0.16 -0.11 0.04 0.05 -0.06 -0.1 0.02 -0.12 0.05 -0.16 -0.06 0.08 -0.04 -0.06 0.51 0.45 0.35 0.47 0.22 0.29 1 0.31 0.37 0.1 0.36 0.44 0.37 0.48 0.36 0.52 0.27 0.33 0.51 0.37 0.21 0.38 0.58 0.47 0.37 0.42 0.52 0.41 0.46 0.23
POST1_8 -0.05 0.05 -0.12 -0.11 -0.08 0 -0.1 -0.14 -0.16 0.12 0.14 -0.26 -0.01 -0.13 -0.05 -0.05 -0.22 0.03 0.02 -0.08 -0.08 -0.1 0.08 -0.07 -0.16 -0.05 -0.11 -0.07 -0.02 -0.04 0.39 0.53 0.43 0.2 0.1 0.03 0.31 1 0.09 0.22 0.41 0.41 0.51 0.28 0.09 0.46 0.55 0.08 0.33 0.22 0.44 0.6 0.3 0.26 0.04 0.19 0.37 0.27 0.56 0.34
POST1_9 -0.19 -0.27 -0.34 0 -0.08 -0.22 -0.16 -0.38 -0.07 -0.06 -0.24 -0.4 -0.18 -0.11 0 -0.1 -0.25 -0.19 -0.15 -0.2 -0.05 -0.26 -0.26 -0.13 -0.21 -0.26 -0.37 -0.25 0.04 -0.05 0.4 0.52 0.44 0.42 -0.02 0.13 0.37 0.09 1 0.24 0.38 0.23 0.4 0.38 0.4 0.3 0.2 0.32 0.5 0.47 0.09 0.44 0.66 0.45 0.13 0.46 0.43 0.47 0.23 0.19
POST1_10 -0.11 -0.03 -0.11 0.19 0.03 -0.11 0.1 -0.11 0.06 0.04 0.11 0.06 0.02 -0.12 -0.08 -0.18 -0.17 -0.13 0.26 0.19 -0.1 -0.18 -0.01 0.12 0.2 -0.2 -0.14 0.07 0.14 0.11 0.24 0.28 0.45 0.39 0.17 0 0.1 0.22 0.24 1 0.34 0.3 0.38 0.18 0.31 0.44 0.39 0.27 0.37 0.02 0.47 0.33 0.14 0.2 0.38 0.26 0.34 0.21 0.23 0.46
POST1_11 -0.01 -0.04 -0.08 0.14 -0.14 -0.1 -0.13 -0.17 0.12 0.16 0.25 -0.09 0.05 -0.23 -0.11 -0.26 -0.18 -0.05 0.12 0.2 -0.1 -0.1 -0.04 0.02 0.1 -0.16 -0.22 0.03 0.12 0.07 0.37 0.46 0.17 0.18 0.2 -0.06 0.36 0.41 0.38 0.34 1 0.29 0.16 -0.01 -0.02 0.44 0.22 0.28 0.31 0.16 0.37 0.18 0.36 0.35 0.16 0.2 0.52 0.35 0.16 0.19
POST1_12 0.08 -0.01 -0.07 0.05 -0.04 -0.14 0.01 -0.27 0.15 0.28 0.14 -0.01 -0.18 -0.03 0.09 -0.01 -0.13 0.09 0.02 0.01 0.12 0.03 -0.01 -0.16 0 -0.05 -0.05 0.07 0.02 0 0.24 0.37 0.59 0.42 0.23 0.45 0.44 0.41 0.23 0.3 0.29 1 0.38 0.27 -0.06 0.34 0.43 0.16 0.49 0.37 0.54 0.27 0.2 0.51 0.32 0.2 0.33 0.49 0.35 0.46
POST1_13 -0.13 -0.3 -0.32 -0.04 -0.26 -0.21 -0.07 -0.36 -0.31 -0.14 -0.25 -0.31 -0.23 -0.19 -0.11 -0.11 -0.53 -0.19 -0.17 -0.1 -0.14 -0.36 -0.24 -0.11 -0.24 -0.26 -0.3 -0.21 -0.16 -0.14 0.52 0.48 0.62 0.4 -0.06 0.33 0.37 0.51 0.4 0.38 0.16 0.38 1 0.24 0.22 0.48 0.45 0.46 0.38 0.24 0.23 0.68 0.48 0.39 0.19 0.23 0.43 0.39 0.63 0.36
POST1_14 -0.08 -0.04 -0.18 -0.14 0.19 -0.18 0.02 -0.04 -0.11 0.06 -0.22 -0.32 -0.14 0.14 0.24 0 -0.09 -0.02 0 -0.13 0.01 -0.13 0.03 0.02 -0.21 -0.04 0 -0.11 -0.12 0.03 0.38 0.49 0.4 0.41 0.07 0.46 0.48 0.28 0.38 0.18 -0.01 0.27 0.24 1 0.31 0.27 0.22 0.14 0.55 0.58 0.25 0.47 0.44 0.36 0.25 0.44 0.31 0.46 0.4 0.18
POST1_15 0.04 -0.01 -0.18 0.07 0.09 -0.1 0.07 -0.04 0.04 0.04 -0.03 -0.2 -0.07 0.14 0.15 0.15 0.06 -0.15 0.1 -0.13 -0.03 0.1 0.12 -0.06 -0.14 -0.11 0 -0.02 0.06 0.1 0.37 0.29 0.25 0.36 0.23 0.35 0.36 0.09 0.4 0.31 -0.02 -0.06 0.22 0.31 1 0.32 0.29 0.3 0.38 0.19 0.11 0.56 0.46 0.07 0.24 0.56 0.29 0.25 0.17 0.21
POST1_16 -0.01 -0.21 -0.18 0.04 -0.24 -0.16 -0.07 -0.18 -0.25 0.04 -0.07 -0.18 -0.12 -0.17 -0.1 -0.12 -0.26 -0.12 -0.1 -0.04 -0.29 -0.16 -0.06 -0.17 0.1 -0.27 -0.12 -0.03 -0.15 -0.07 0.48 0.36 0.46 0.24 0.31 0.14 0.52 0.46 0.3 0.44 0.44 0.34 0.48 0.27 0.32 1 0.4 0.09 0.19 0.14 0.45 0.46 0.41 0.22 0.28 0.48 0.45 0.17 0.43 0.34
POST1_17 -0.19 -0.13 -0.22 0.16 -0.1 -0.12 -0.04 -0.28 -0.11 0.07 -0.08 -0.18 -0.05 -0.02 -0.15 -0.14 -0.26 -0.08 0.02 -0.03 -0.12 -0.11 -0.09 0 -0.17 -0.14 -0.27 -0.1 0.09 -0.05 0.09 0.29 0.42 0.53 0.33 0.18 0.27 0.55 0.2 0.39 0.22 0.43 0.45 0.22 0.29 0.4 1 0.14 0.09 -0.09 0.47 0.5 0.24 0.08 0.28 0.18 0.18 0.22 0.43 0.59
POST1_18 -0.1 -0.24 -0.07 0.14 -0.13 -0.15 -0.06 -0.24 0.01 0.04 0 -0.12 -0.2 -0.07 -0.02 -0.18 -0.4 -0.02 0.04 0.11 0.01 -0.22 -0.17 0.14 -0.19 -0.2 -0.28 -0.1 0.02 0.14 0.45 0.3 0.26 0.26 0.05 0.35 0.33 0.08 0.32 0.27 0.28 0.16 0.46 0.14 0.3 0.09 0.14 1 0.28 -0.06 0.09 0.38 0.35 0.31 0.21 0.39 0.47 0.35 0.12 0.03
POST1_19 0 0.06 -0.22 -0.1 0.14 -0.19 0.01 -0.14 0.11 0.12 0.1 -0.19 -0.24 -0.05 0.25 0.06 -0.1 -0.13 0.11 -0.05 0.16 -0.05 0.02 -0.18 -0.1 -0.1 0.04 -0.06 0.04 -0.02 0.54 0.57 0.53 0.41 0.01 0.41 0.51 0.33 0.5 0.37 0.31 0.49 0.38 0.55 0.38 0.19 0.09 0.28 1 0.5 0.32 0.54 0.46 0.65 0.11 0.46 0.46 0.56 0.34 0.28
POST1_20 0.2 0.08 -0.13 -0.12 0.14 -0.09 0.05 -0.03 0.14 0.11 -0.07 -0.25 0.04 0.15 0.25 0.15 0.13 0.03 -0.01 -0.12 0.09 0.06 0.15 -0.04 -0.15 0.07 0.03 0.05 -0.09 0.09 0.35 0.55 0.32 0.3 -0.05 0.43 0.37 0.22 0.47 0.02 0.16 0.37 0.24 0.58 0.19 0.14 -0.09 -0.06 0.5 1 0.1 0.26 0.47 0.39 0.29 0.14 0.33 0.62 0.35 0.09
POST1_21 0 0.08 -0.02 0.2 0.09 0.05 0.16 -0.16 -0.04 0.37 0.15 -0.11 -0.01 0.2 0.11 0.03 -0.01 0.11 0.14 0.07 0.13 0.08 0.06 0.02 0.06 0.09 0.01 0.03 0.14 0.08 0.14 0.26 0.32 0.34 0.48 0.26 0.21 0.44 0.09 0.47 0.37 0.54 0.23 0.25 0.11 0.45 0.47 0.09 0.32 0.1 1 0.27 0.11 0.01 0.05 0.31 0.27 0.36 0.2 0.33
POST1_22 -0.05 -0.07 -0.21 -0.06 -0.12 -0.08 0.04 -0.22 -0.25 -0.01 -0.18 -0.33 -0.12 0.04 0.04 -0.02 -0.31 0 0 -0.18 -0.03 -0.17 -0.04 -0.04 -0.27 -0.08 -0.14 -0.22 -0.1 0.03 0.51 0.61 0.57 0.43 0.01 0.4 0.38 0.6 0.44 0.33 0.18 0.27 0.68 0.47 0.56 0.46 0.5 0.38 0.54 0.26 0.27 1 0.49 0.28 0.04 0.52 0.47 0.41 0.49 0.3
POST1_23 -0.08 -0.22 -0.29 0.15 0.12 -0.26 -0.04 -0.11 0.03 0.05 -0.1 -0.28 -0.2 0.01 0.21 -0.03 -0.09 -0.13 -0.02 -0.06 0.04 0.05 -0.12 -0.14 -0.19 -0.09 -0.1 -0.03 -0.05 -0.06 0.63 0.58 0.26 0.31 0.08 0.28 0.58 0.3 0.66 0.14 0.36 0.2 0.48 0.44 0.46 0.41 0.24 0.35 0.46 0.47 0.11 0.49 1 0.28 0.01 0.48 0.36 0.47 0.26 0.35
POST1_24 -0.07 -0.17 -0.11 -0.23 -0.22 -0.29 -0.18 -0.37 0.03 0.01 0.02 -0.11 -0.23 -0.39 -0.07 -0.1 -0.28 -0.14 -0.15 -0.15 -0.08 -0.3 -0.09 -0.17 -0.18 -0.38 -0.16 -0.14 -0.11 -0.02 0.51 0.46 0.49 0.23 -0.09 0.3 0.47 0.26 0.45 0.2 0.35 0.51 0.39 0.36 0.07 0.22 0.08 0.31 0.65 0.39 0.01 0.28 0.28 1 0.13 0.2 0.43 0.43 0.38 0.24
POST1_25 0.11 -0.04 -0.2 0.02 -0.05 -0.16 -0.1 -0.02 0.16 -0.04 0.01 -0.08 0.01 -0.06 -0.06 -0.11 -0.17 -0.2 0.11 0.18 -0.22 -0.11 0.07 0.04 0.1 -0.2 -0.19 0.14 0.05 0.02 0.06 0.14 0.38 0.45 0.18 0.27 0.37 0.04 0.13 0.38 0.16 0.32 0.19 0.25 0.24 0.28 0.28 0.21 0.11 0.29 0.05 0.04 0.01 0.13 1 0.09 0.33 0.25 0.37 0.15
POST1_26 0.02 -0.06 -0.16 -0.12 0.04 -0.09 -0.01 -0.1 -0.16 0.08 -0.08 -0.26 -0.22 0.04 0.2 0.13 -0.16 -0.02 -0.04 -0.18 -0.02 -0.09 -0.06 -0.05 -0.06 -0.04 0.05 -0.22 -0.05 -0.02 0.42 0.4 0.5 0.17 0.11 0.32 0.42 0.19 0.46 0.26 0.2 0.2 0.23 0.44 0.56 0.48 0.18 0.39 0.46 0.14 0.31 0.52 0.48 0.2 0.09 1 0.49 0.19 -0.03 -0.03
POST1_27 -0.01 -0.05 -0.3 -0.12 -0.2 -0.32 -0.1 -0.22 -0.06 0.04 -0.01 -0.33 -0.2 -0.23 0.07 -0.24 -0.39 -0.17 0.02 0.09 -0.21 -0.19 -0.03 -0.16 -0.08 -0.16 -0.28 -0.02 -0.09 -0.13 0.39 0.44 0.55 0.42 0.06 0.23 0.52 0.37 0.43 0.34 0.52 0.33 0.43 0.31 0.29 0.45 0.18 0.47 0.46 0.33 0.27 0.47 0.36 0.43 0.33 0.49 1 0.36 0.17 -0.11
POST1_28 -0.09 -0.11 -0.29 0.08 0.04 -0.27 0 -0.22 0.05 0.08 -0.14 -0.27 -0.13 0.15 -0.03 -0.09 -0.08 -0.1 0.05 -0.15 -0.04 -0.04 -0.04 -0.08 -0.21 -0.01 -0.2 -0.02 -0.17 0.01 0.46 0.66 0.27 0.43 0.05 0.56 0.41 0.27 0.47 0.21 0.35 0.49 0.39 0.46 0.25 0.17 0.22 0.35 0.56 0.62 0.36 0.41 0.47 0.43 0.25 0.19 0.36 1 0.26 0.11
POST1_29 0.01 -0.04 0.01 0.04 -0.06 0.09 -0.02 -0.07 -0.1 0.05 0 -0.07 0.14 -0.06 -0.07 0.04 -0.14 0.04 -0.03 0.02 -0.04 -0.21 0.18 0.07 -0.09 -0.18 -0.03 0.01 0.05 0.09 0.31 0.4 0.43 0.4 0.16 0.22 0.46 0.56 0.23 0.23 0.16 0.35 0.63 0.4 0.17 0.43 0.43 0.12 0.34 0.35 0.2 0.49 0.26 0.38 0.37 -0.03 0.17 0.26 1 0.37
POST1_30 -0.02 -0.15 -0.08 0.21 0 -0.11 0.02 -0.25 0.15 0.14 0.12 -0.01 -0.14 -0.09 0.06 -0.06 -0.1 -0.07 0.07 0.08 0.14 0.05 -0.16 -0.06 -0.06 -0.25 -0.11 0.01 0.19 0.1 0.29 0.18 0.3 0.36 0.28 0.16 0.23 0.34 0.19 0.46 0.19 0.46 0.36 0.18 0.21 0.34 0.59 0.03 0.28 0.09 0.33 0.3 0.35 0.24 0.15 -0.03 -0.11 0.11 0.37 1
# mittleres Cronbach´s Alpha zwischen Pre-MZP und Post-MZP:
PRE_alpha = CronbachAlpha(EMA_30.30[pre_30mzp])
POST_alpha = CronbachAlpha(EMA_30.30[post_30mzp])
EMA_30.30_Alpha = FisherZInv(mean(c(FisherZ(PRE_alpha), FisherZ(POST_alpha))))

Korrelation zwischen den Pre- und Post-Intervall-Mittelwerten = -0.154.
Durchschnittliche paarweise Korrelation zwischen aufeinanderfolgenden Pre-MZP (Fisher-Z-transformiert): r = 0.41.
Durchschnittliche paarweise Korrelation zwischen aufeinanderfolgenden Post-MZP (Fisher-Z-transformiert): r = 0.31.
Mittleres Cronbach´s Alpha zwischen Pre-MZP und Post-MZP = 0.944.


1.4.3 EMA_5.5_Window (je 5 MZP)

# Korrelationsmatrix von PRE- und POST-MZP:
EMA_5.5_Window_KorMat = cor(EMA_5.5_Window[, c(pre_5mzp, post_5mzp)]) %>% 
  round(., digits = 2)

# durchschnittliche paarweise Korrelation zwischen aufeinanderfolgenden MZP (beachte: ohne Fisher-Z-Transformation):
pre_inter_item_rtt = 0L
for (i in 1:4) {
  pre_inter_item_rtt = pre_inter_item_rtt + FisherZ(EMA_5.5_Window_KorMat[i,i+1])
}
pre_inter_item_rtt = FisherZInv(pre_inter_item_rtt / 4)

post_inter_item_rtt = 0L
for (i in 5:9) {
  post_inter_item_rtt = post_inter_item_rtt + FisherZ(EMA_5.5_Window_KorMat[i,i+1])
}
post_inter_item_rtt = FisherZInv(post_inter_item_rtt / 4)


for (i in 1:9) {
  EMA_5.5_Window_KorMat[i, i+1] = cell_spec(EMA_5.5_Window_KorMat[i, i+1], "html", bold = TRUE)
}

rownames(EMA_5.5_Window_KorMat) = cell_spec(rownames(EMA_5.5_Window_KorMat), "html", bold = TRUE)

EMA_5.5_Window_KorMat %>%
  kable(., format = "html", escape = FALSE) %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"),
                full_width = FALSE, fixed_thead = T)
PRE1_1 PRE1_2 PRE1_3 PRE1_4 PRE1_5 POST1_1 POST1_2 POST1_3 POST1_4 POST1_5
PRE1_1 1 0.32 0.48 0.37 0.46 -0.18 -0.17 -0.27 -0.02 -0.11
PRE1_2 0.32 1 0.49 0.04 0.28 0.04 0.06 -0.16 -0.02 -0.21
PRE1_3 0.48 0.49 1 0.46 0.28 -0.25 0.15 -0.08 -0.1 -0.05
PRE1_4 0.37 0.04 0.46 1 0.2 -0.25 0.18 -0.02 -0.06 -0.02
PRE1_5 0.46 0.28 0.28 0.2 1 0 -0.01 0.1 0.33 -0.02
POST1_1 -0.18 0.04 -0.25 -0.25 0 1 0.38 0.03 0.22 0.36
POST1_2 -0.17 0.06 0.15 0.18 -0.01 0.38 1 0.31 0.23 0.14
POST1_3 -0.27 -0.16 -0.08 -0.02 0.1 0.03 0.31 1 0.52 0.32
POST1_4 -0.02 -0.02 -0.1 -0.06 0.33 0.22 0.23 0.52 1 0.44
POST1_5 -0.11 -0.21 -0.05 -0.02 -0.02 0.36 0.14 0.32 0.44 1
# mittleres Cronbach´s Alpha zwischen Pre-MZP und Post-MZP:
PRE_alpha = CronbachAlpha(EMA_5.5_Window[pre_5mzp])
POST_alpha = CronbachAlpha(EMA_5.5_Window[post_5mzp])
EMA_5.5_Window_Alpha = FisherZInv(mean(c(FisherZ(PRE_alpha), FisherZ(POST_alpha))))

Korrelation zwischen den Pre- und Post-Intervall-Mittelwerten = -0.119.
Durchschnittliche paarweise Korrelation zwischen aufeinanderfolgenden Pre-MZP (Fisher-Z-transformiert): r = 0.37.
Durchschnittliche paarweise Korrelation zwischen aufeinanderfolgenden Post-MZP (Fisher-Z-transformiert): r = 0.42.
Mittleres Cronbach´s Alpha zwischen Pre-MZP und Post-MZP = 0.696.


1.4.4 EMA_5.5_Days (je 5 MZP)

# Korrelationsmatrix von PRE- und POST-MZP:
EMA_5.5_Days_KorMat = cor(EMA_5.5_Days[, c(pre_5mzp, post_5mzp)]) %>% 
  round(., digits = 2)

# durchschnittliche paarweise Korrelation zwischen aufeinanderfolgenden MZP (beachte: ohne Fisher-Z-Transformation):
pre_inter_item_rtt = 0L
for (i in 1:4) {
  pre_inter_item_rtt = pre_inter_item_rtt + FisherZ(EMA_5.5_Days_KorMat[i,i+1])
}
pre_inter_item_rtt = FisherZInv(pre_inter_item_rtt / 4)

post_inter_item_rtt = 0L
for (i in 5:9) {
  post_inter_item_rtt = post_inter_item_rtt + FisherZ(EMA_5.5_Days_KorMat[i,i+1])
}
post_inter_item_rtt = FisherZInv(post_inter_item_rtt / 4)


for (i in 1:9) {
  EMA_5.5_Days_KorMat[i, i+1] = cell_spec(EMA_5.5_Days_KorMat[i, i+1], "html", bold = TRUE)
}

rownames(EMA_5.5_Days_KorMat) = cell_spec(rownames(EMA_5.5_Days_KorMat), "html", bold = TRUE)

EMA_5.5_Days_KorMat %>%
  kable(., format = "html", escape = FALSE) %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"),
                full_width = FALSE, fixed_thead = T)
PRE1_1 PRE1_2 PRE1_3 PRE1_4 PRE1_5 POST1_1 POST1_2 POST1_3 POST1_4 POST1_5
PRE1_1 1 0.29 0.58 0.38 0.39 -0.21 -0.32 -0.01 -0.39 -0.25
PRE1_2 0.29 1 0.36 0.41 0.49 0 0.11 -0.13 -0.16 0.06
PRE1_3 0.58 0.36 1 0.33 0.41 0.05 -0.21 -0.18 -0.33 -0.3
PRE1_4 0.38 0.41 0.33 1 0.23 -0.21 0.13 -0.04 -0.32 -0.02
PRE1_5 0.39 0.49 0.41 0.23 1 -0.02 -0.09 -0.24 -0.18 -0.14
POST1_1 -0.21 0 0.05 -0.21 -0.02 1 0.09 0.06 0.6 0.17
POST1_2 -0.32 0.11 -0.21 0.13 -0.09 0.09 1 0.29 0.3 0.4
POST1_3 -0.01 -0.13 -0.18 -0.04 -0.24 0.06 0.29 1 0.25 0.44
POST1_4 -0.39 -0.16 -0.33 -0.32 -0.18 0.6 0.3 0.25 1 0.26
POST1_5 -0.25 0.06 -0.3 -0.02 -0.14 0.17 0.4 0.44 0.26 1
# mittleres Cronbach´s Alpha zwischen Pre-MZP und Post-MZP:
PRE_alpha = CronbachAlpha(EMA_5.5_Days[pre_5mzp])
POST_alpha = CronbachAlpha(EMA_5.5_Days[post_5mzp])
EMA_5.5_Days_Alpha = FisherZInv(mean(c(FisherZ(PRE_alpha), FisherZ(POST_alpha))))

Korrelation zwischen den Pre- und Post-Intervall-Mittelwerten = -0.285.
Durchschnittliche paarweise Korrelation zwischen aufeinanderfolgenden Pre-MZP (Fisher-Z-transformiert): r = 0.3.
Durchschnittliche paarweise Korrelation zwischen aufeinanderfolgenden Post-MZP (Fisher-Z-transformiert): r = 0.22.
Mittleres Cronbach´s Alpha zwischen Pre-MZP und Post-MZP = 0.714.


1.5 Pre-Post-Differenz

Verteilungen der Pre-Post-Mittelwerts-Veränderungen

temp = tibble(MeanDiffs = c(EMA_5.5$MeanDiff, EMA_30.30$MeanDiff, EMA_5.5_Window$MeanDiff, EMA_5.5_Days$MeanDiff),
              Datasets = rep(c("EMA_5.5", "EMA_30.30", "EMA_5.5_Window", "EMA_5.5_Days"), each = length(EMA_5.5$MeanDiff)))

temp %>%
  ggplot(aes(x = MeanDiffs, fill = Datasets)) +
    geom_histogram(alpha = 0.2, binwidth = 1, position = "identity") +
    labs(title = "Pre-Post-Differences", x = "PHQ-9 Pre-Post-Difference")

#scatter.hist(EMA_5.5$MeanDiff, EMA_30.30$MeanDiff, xlab = "EMA_5.5$MeanDiff",
#  ylab = "EMA_30.30$MeanDiff", ellipse = FALSE, grid = TRUE, col = c("dodgerblue", "darkorange"))

#scatter.hist(EMA_5.5$MeanDiff, EMA_5.5_Window$MeanDiff, xlab = "EMA_5.5$MeanDiff",
#  ylab = "EMA_5.5_Window$MeanDiff", ellipse = FALSE, grid = TRUE, col = c("dodgerblue", "darkorange"))

#scatter.hist(EMA_5.5$MeanDiff, EMA_5.5_Days$MeanDiff, xlab = "EMA_5.5$MeanDiff",
#  ylab = "EMA_5.5_Days$MeanDiff", ellipse = FALSE, grid = TRUE, col = c("dodgerblue", "darkorange"))

#scatter.hist(EMA_5.5_Window$MeanDiff, EMA_5.5_Days$MeanDiff, xlab = "EMA_5.5_Window$MeanDiff",
#  ylab = "EMA_5.5_Days$MeanDiff", ellipse = FALSE, grid = TRUE, col = c("dodgerblue", "darkorange"))

Korrelation zwischen den Pre-Post-Differenzen in EMA_5.5 und EMA_30.30 = 1.
Korrelation zwischen den Pre-Post-Differenzen in EMA_5.5_Window und EMA_30.30 = 0.919.
Korrelation zwischen den Pre-Post-Differenzen in EMA_5.5_Days und EMA_30.30 = 0.926.

Prozentuale Überlappung der Pre-Post-Mittelwerts-Veränderungen

# Overlap-Plots zum Vergleich
final.plot(list(EMA_5.5_MeanDiff = EMA_5.5$MeanDiff, EMA_30.30_MeanDiff = EMA_30.30$MeanDiff), 
           overlap(list(EMA_5.5_MeanDiff = EMA_5.5$MeanDiff, EMA_30.30_MeanDiff = EMA_30.30$MeanDiff))$OV)

final.plot(list(EMA_5.5_Window_MeanDiff = EMA_5.5_Window$MeanDiff, EMA_30.30_MeanDiff = EMA_30.30$MeanDiff), 
           overlap(list(EMA_5.5_Window_MeanDiff = EMA_5.5_Window$MeanDiff, EMA_30.30_MeanDiff = EMA_30.30$MeanDiff))$OV)

final.plot(list(EMA_5.5_Days_MeanDiff = EMA_5.5_Days$MeanDiff, EMA_30.30_MeanDiff = EMA_30.30$MeanDiff), 
           overlap(list(EMA_5.5_Days_MeanDiff = EMA_5.5_Days$MeanDiff, EMA_30.30_MeanDiff = EMA_30.30$MeanDiff))$OV)

final.plot(list(EMA_5.5_Window_MeanDiff = EMA_5.5_Window$MeanDiff, EMA_5.5_Days_MeanDiff = EMA_5.5_Days$MeanDiff), 
           overlap(list(EMA_5.5_Window_MeanDiff = EMA_5.5_Window$MeanDiff, EMA_5.5_Days_MeanDiff = EMA_5.5_Days$MeanDiff))$OV)


1.5.1 Cohen´s d

Cohen´s d (mit gepoolten SDs) vom Pre- zum Post-Intervall in EMA_5.5 (je 5 MZP)

\[ d = \frac{\overline{x_{1}} - \overline{x_{2}}} {\sqrt{0.5 \cdot (s_{x}^2 + s_{y}^2)}} \]

\(\overline{x_{1}}\) = mean of subject´s pretest scores, \(\overline{x_{2}}\) = mean of subject´s posttest scores, \(s_{x}\) = individual standard deviation of pretest time points, \(s_{y}\) = individual standard deviation of posttest time points

EMA_5.5$Cohen_d = (EMA_5.5$PRE_Mean - EMA_5.5$POST_Mean) / sqrt(0.5 * (EMA_5.5$ind.pretestSD^2 + EMA_5.5$ind.posttestSD^2))

# Sollen Cohen_d %in% c(-Inf,Inf) ein-/ausgeschlossen werden?
#EMA_5.5 = EMA_5.5 %>% 
#  within(., {Cohen_d[Cohen_d %in% c(-Inf,Inf)] = NA})

#hist(EMA_5.5$Cohen_d, col = "lightblue1", main = "EMA_5.5$Cohen_d")

cohen_d_5.5 = (mean(EMA_5.5$PRE_Mean) - mean(EMA_5.5$POST_Mean)) / sqrt(0.5 * (mean(EMA_5.5$ind.pretestSD)^2 +
  mean(EMA_5.5$ind.posttestSD)^2))

final.plot(list(EMA_5.5_PRE_Mean = EMA_5.5$PRE_Mean, EMA_5.5_POST_Mean = EMA_5.5$POST_Mean), 
           overlap(list(EMA_5.5_PRE_Mean = EMA_5.5$PRE_Mean, EMA_5.5_POST_Mean = EMA_5.5$POST_Mean))$OV)

Gepoolte Varianz zwischen Pre- und Post-Intervall-Mittelwerten in EMA_5.5 = 3.239.
Durchschnittliches Cohen´s d zwischen Pre- und Post-Mittelwerten (für jede Person einzeln berechnet) in EMA_5.5 = 1.026.
Durchschnittliches Cohen´s d zwischen Pre- und Post-Mittelwerten in EMA_5.5 = 0.902.


Cohen´s d (mit gepoolten SDs) vom Pre- zum Post-Intervall in den erweiterten Intervall-Daten (je 30 MZP)

EMA_30.30$Cohen_d = (EMA_30.30$PRE_Mean - EMA_30.30$POST_Mean) / sqrt(0.5 * (EMA_30.30$ind.pretestSD^2 + EMA_30.30$ind.posttestSD^2))

# Sollen Cohen_d %in% c(-Inf,Inf) ein-/ausgeschlossen werden?
#EMA_30.30 = EMA_30.30 %>% 
#  within(., {Cohen_d[Cohen_d %in% c(-Inf,Inf)] = NA})

#hist(EMA_30.30$Cohen_d, col = "lightblue1", main = "EMA_30.30$Cohen_d")

cohen_d_30.30 = (mean(EMA_30.30$PRE_Mean) - mean(EMA_30.30$POST_Mean)) / sqrt(0.5 * (mean(EMA_30.30$ind.pretestSD)^2 +
  mean(EMA_30.30$ind.posttestSD)^2))

final.plot(list(EMA_30.30_PRE_Mean = EMA_30.30$PRE_Mean, EMA_30.30_POST_Mean = EMA_30.30$POST_Mean), 
           overlap(list(EMA_30.30_PRE_Mean = EMA_30.30$PRE_Mean, EMA_30.30_POST_Mean = EMA_30.30$POST_Mean))$OV)

Gepoolte Varianz zwischen Pre- und Post-Intervall-Mittelwerten in EMA_30.30 = 3.239.
Durchschnittliches Cohen´s d zwischen Pre- und Post-Mittelwerten (für jede Person einzeln berechnet) in EMA_30.30 = 1.128.
Durchschnittliches Cohen´s d zwischen Pre- und Post-Mittelwerten in EMA_30.30 = 0.992.


Cohen´s d (mit gepoolten SDs) vom Pre- zum Post-Intervall in EMA_5.5_Window (je 5 MZP)

EMA_5.5_Window$Cohen_d = (EMA_5.5_Window$PRE_Mean - EMA_5.5_Window$POST_Mean) / sqrt(0.5 * (EMA_5.5_Window$ind.pretestSD^2 + EMA_5.5_Window$ind.posttestSD^2))

# Sollen Cohen_d %in% c(-Inf,Inf) ein-/ausgeschlossen werden?
#EMA_5.5_Window = EMA_5.5_Window %>% 
#  within(., {Cohen_d[Cohen_d %in% c(-Inf,Inf)] = NA})

#hist(EMA_5.5_Window$Cohen_d, col = "lightblue1", main = "EMA_5.5_Window$Cohen_d")

cohen_d_5.5_Window = (mean(EMA_5.5_Window$PRE_Mean) - mean(EMA_5.5_Window$POST_Mean)) / sqrt(0.5 * (mean(EMA_5.5_Window$ind.pretestSD)^2 + mean(EMA_5.5_Window$ind.posttestSD)^2))

final.plot(list(EMA_5.5_Window_PRE_Mean = EMA_5.5_Window$PRE_Mean, EMA_5.5_Window_POST_Mean = EMA_5.5_Window$POST_Mean),
    overlap(list(EMA_5.5_Window_PRE_Mean = EMA_5.5_Window$PRE_Mean, EMA_5.5_Window_POST_Mean = EMA_5.5_Window$POST_Mean))$OV)

Gepoolte Varianz zwischen Pre- und Post-Intervall-Mittelwerten in EMA_5.5_Window = 3.5.
Durchschnittliches Cohen´s d zwischen Pre- und Post-Mittelwerten (für jede Person einzeln berechnet) in EMA_5.5_Window = 1.139.
Durchschnittliches Cohen´s d zwischen Pre- und Post-Mittelwerten in EMA_5.5_Window = 0.972.


Cohen´s d (mit gepoolten SDs) vom Pre- zum Post-Intervall in EMA_5.5_Days (je 5 MZP)

EMA_5.5_Days$Cohen_d = (EMA_5.5_Days$PRE_Mean - EMA_5.5_Days$POST_Mean) / sqrt(0.5 * (EMA_5.5_Days$ind.pretestSD^2 + EMA_5.5_Days$ind.posttestSD^2))

# Sollen Cohen_d %in% c(-Inf,Inf) ein-/ausgeschlossen werden?
#EMA_5.5_Days = EMA_5.5_Days %>% 
#  within(., {Cohen_d[Cohen_d %in% c(-Inf,Inf)] = NA})

#hist(EMA_5.5_Days$Cohen_d, col = "lightblue1", main = "EMA_5.5_Days$Cohen_d")

cohen_d_5.5_Days = (mean(EMA_5.5_Days$PRE_Mean) - mean(EMA_5.5_Days$POST_Mean)) / sqrt(0.5 * (mean(EMA_5.5_Days$ind.pretestSD)^2 + mean(EMA_5.5_Days$ind.posttestSD)^2))

final.plot(list(EMA_5.5_Days_PRE_Mean = EMA_5.5_Days$PRE_Mean, EMA_5.5_Days_POST_Mean = EMA_5.5_Days$POST_Mean),
    overlap(list(EMA_5.5_Days_PRE_Mean = EMA_5.5_Days$PRE_Mean, EMA_5.5_Days_POST_Mean = EMA_5.5_Days$POST_Mean))$OV)

Gepoolte Varianz zwischen Pre- und Post-Intervall-Mittelwerten in EMA_5.5_Days = 3.679.
Durchschnittliches Cohen´s d zwischen Pre- und Post-Mittelwerten (für jede Person einzeln berechnet) in EMA_5.5_Days = 1.181.
Durchschnittliches Cohen´s d zwischen Pre- und Post-Mittelwerten in EMA_5.5_Days = 1.


Ab hier nur noch Vergleiche in EMA_30.30, EMA_5.5_Window und EMA_5.5_Days:


1.6 Klinische PHQ-9-Interpretation

PHQ_Int = tibble(PHQ_Score = c("0-4","5-9","10-14","15-19","20-27"),
       Klassifikation = c(0,1,2,3,4),
       Interpretation = c("Minimal or none","Mild","Moderate","Moderately severe","Severe"))

1.6.1 EMA_30.30

EMA_30.30 = EMA_30.30 %>% 
  mutate(PRE_Mean_klass = case_when(
    PRE_Mean <= 4 ~ 0,
    PRE_Mean > 4 & PRE_Mean < 10 ~ 1,
    PRE_Mean >= 10 & PRE_Mean < 15 ~ 2,
    PRE_Mean >= 15 & PRE_Mean < 20 ~ 3,
    PRE_Mean >= 20 ~ 4,
    TRUE ~ PRE_Mean
  )
)

temp = EMA_30.30 %>% 
  count(PRE_Mean_klass) %>% 
  mutate(Percentage = round(((n / sum(n)) * 100), digits = 2))

PHQ_Int %>%
  dplyr::rename(PRE_Mean_klass = Klassifikation) %>%
  full_join(., temp) %>% 
  kable() %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = FALSE)
PHQ_Score PRE_Mean_klass Interpretation n Percentage
0-4 0 Minimal or none NA NA
5-9 1 Mild 22 44
10-14 2 Moderate 28 56
15-19 3 Moderately severe NA NA
20-27 4 Severe NA NA
EMA_30.30 = EMA_30.30 %>% 
  mutate(POST_Mean_klass = case_when(
    POST_Mean <= 4 ~ 0,
    POST_Mean > 4 & POST_Mean < 10 ~ 1,
    POST_Mean >= 10 & POST_Mean < 15 ~ 2,
    POST_Mean >= 15 & POST_Mean < 20 ~ 3,
    POST_Mean >= 20 ~ 4,
    TRUE ~ POST_Mean
  )
)

temp = EMA_30.30 %>% 
  count(POST_Mean_klass) %>% 
  mutate(Percentage = round(((n / sum(n)) * 100), digits = 2))

PHQ_Int %>%
  dplyr::rename(POST_Mean_klass = Klassifikation) %>%
  full_join(., temp) %>% 
  kable() %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = FALSE)
PHQ_Score POST_Mean_klass Interpretation n Percentage
0-4 0 Minimal or none 4 8
5-9 1 Mild 34 68
10-14 2 Moderate 12 24
15-19 3 Moderately severe NA NA
20-27 4 Severe NA NA
temp = tibble(Klassifikation = c(EMA_30.30$PRE_Mean_klass, EMA_30.30$POST_Mean_klass),
              MZP = rep(c("PRE_Mean_klass", "POST_Mean_klass"), each = length(EMA_30.30$PRE_Mean_klass)))

temp %>%
  ggplot(aes(x = Klassifikation, fill = MZP)) +
    geom_histogram(alpha = 0.2, binwidth = 1, position = "identity") +
    labs(title = "EMA_30.30: PHQ-9 Classification", x = "Classification")

1.6.2 EMA_5.5_Window

EMA_5.5_Window = EMA_5.5_Window %>% 
  mutate(PRE_Mean_klass = case_when(
    PRE_Mean <= 4 ~ 0,
    PRE_Mean > 4 & PRE_Mean < 10 ~ 1,
    PRE_Mean >= 10 & PRE_Mean < 15 ~ 2,
    PRE_Mean >= 15 & PRE_Mean < 20 ~ 3,
    PRE_Mean >= 20 ~ 4,
    TRUE ~ PRE_Mean
  )
)

temp = EMA_5.5_Window %>% 
  count(PRE_Mean_klass) %>% 
  mutate(Percentage = round(((n / sum(n)) * 100), digits = 2))

PHQ_Int %>%
  dplyr::rename(PRE_Mean_klass = Klassifikation) %>%
  full_join(., temp) %>% 
  kable() %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = FALSE)
PHQ_Score PRE_Mean_klass Interpretation n Percentage
0-4 0 Minimal or none NA NA
5-9 1 Mild 23 46
10-14 2 Moderate 27 54
15-19 3 Moderately severe NA NA
20-27 4 Severe NA NA
EMA_5.5_Window = EMA_5.5_Window %>% 
  mutate(POST_Mean_klass = case_when(
    POST_Mean <= 4 ~ 0,
    POST_Mean > 4 & POST_Mean < 10 ~ 1,
    POST_Mean >= 10 & POST_Mean < 15 ~ 2,
    POST_Mean >= 15 & POST_Mean < 20 ~ 3,
    POST_Mean >= 20 ~ 4,
    TRUE ~ POST_Mean
  )
)

temp = EMA_5.5_Window %>% 
  count(POST_Mean_klass) %>% 
  mutate(Percentage = round(((n / sum(n)) * 100), digits = 2))

PHQ_Int %>%
  dplyr::rename(POST_Mean_klass = Klassifikation) %>%
  full_join(., temp) %>% 
  kable() %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = FALSE)
PHQ_Score POST_Mean_klass Interpretation n Percentage
0-4 0 Minimal or none 4 8
5-9 1 Mild 32 64
10-14 2 Moderate 14 28
15-19 3 Moderately severe NA NA
20-27 4 Severe NA NA
temp = tibble(Klassifikation = c(EMA_5.5_Window$PRE_Mean_klass, EMA_5.5_Window$POST_Mean_klass),
              MZP = rep(c("PRE_Mean_klass", "POST_Mean_klass"), each = length(EMA_5.5_Window$PRE_Mean_klass)))

temp %>%
  ggplot(aes(x = Klassifikation, fill = MZP)) +
    geom_histogram(alpha = 0.2, binwidth = 1, position = "identity") +
    labs(title = "EMA_5.5_Window: PHQ-9 Classification", x = "Classification")

1.6.3 EMA_5.5_Days

EMA_5.5_Days = EMA_5.5_Days %>% 
  mutate(PRE_Mean_klass = case_when(
    PRE_Mean <= 4 ~ 0,
    PRE_Mean > 4 & PRE_Mean < 10 ~ 1,
    PRE_Mean >= 10 & PRE_Mean < 15 ~ 2,
    PRE_Mean >= 15 & PRE_Mean < 20 ~ 3,
    PRE_Mean >= 20 ~ 4,
    TRUE ~ PRE_Mean
  )
)

temp = EMA_5.5_Days %>% 
  count(PRE_Mean_klass) %>% 
  mutate(Percentage = round(((n / sum(n)) * 100), digits = 2))

PHQ_Int %>%
  dplyr::rename(PRE_Mean_klass = Klassifikation) %>%
  full_join(., temp) %>% 
  kable() %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = FALSE)
PHQ_Score PRE_Mean_klass Interpretation n Percentage
0-4 0 Minimal or none NA NA
5-9 1 Mild 24 48
10-14 2 Moderate 26 52
15-19 3 Moderately severe NA NA
20-27 4 Severe NA NA
EMA_5.5_Days = EMA_5.5_Days %>% 
  mutate(POST_Mean_klass = case_when(
    POST_Mean <= 4 ~ 0,
    POST_Mean > 4 & POST_Mean < 10 ~ 1,
    POST_Mean >= 10 & POST_Mean < 15 ~ 2,
    POST_Mean >= 15 & POST_Mean < 20 ~ 3,
    POST_Mean >= 20 ~ 4,
    TRUE ~ POST_Mean
  )
)

temp = EMA_5.5_Days %>% 
  count(POST_Mean_klass) %>% 
  mutate(Percentage = round(((n / sum(n)) * 100), digits = 2))

PHQ_Int %>%
  dplyr::rename(POST_Mean_klass = Klassifikation) %>%
  full_join(., temp) %>% 
  kable() %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = FALSE)
PHQ_Score POST_Mean_klass Interpretation n Percentage
0-4 0 Minimal or none 6 12
5-9 1 Mild 32 64
10-14 2 Moderate 12 24
15-19 3 Moderately severe NA NA
20-27 4 Severe NA NA
temp = tibble(Klassifikation = c(EMA_5.5_Days$PRE_Mean_klass, EMA_5.5_Days$POST_Mean_klass),
              MZP = rep(c("PRE_Mean_klass", "POST_Mean_klass"), each = length(EMA_5.5_Days$PRE_Mean_klass)))

temp %>%
  ggplot(aes(x = Klassifikation, fill = MZP)) +
    geom_histogram(alpha = 0.2, binwidth = 1, position = "identity") +
    labs(title = "EMA_5.5_Days: PHQ-9 Classification", x = "Classification")


1.7 Percentage Change (PC)


\[ PC = \Bigl(1 - \frac{\overline{x_{2}}} {\overline{x_{1}}}\Bigr) \cdot 100 \]

\(\overline{x_{2}}\) = mean of subject´s posttest scores, \(\overline{x_{1}}\) = mean of subject´s pretest scores

Interpretation des Percentage Change:

PC_Int = tibble(PC = c("PC <= -50","-50 < PC <= -25","-25 < PC < 25","25 <= PC < 50","PC >= 50"),
                Klassifikation = c(-2,-1,0,1,2),
                Interpretation = c("starke Verschlechterung","Verschlechterung","keine Veränderung",
                                   "Verbesserung","starke Verbesserung"))

1.7.1 EMA_30.30

EMA_30.30$Mean_PC = (1-(EMA_30.30$POST_Mean / EMA_30.30$PRE_Mean)) * 100

# Sollen Mean_PC %in% c(-Inf,Inf) ein-/ausgeschlossen werden?
#EMA_30.30 = EMA_30.30 %>% 
#  within(., {Mean_PC[Mean_PC %in% c(-Inf,Inf)] = NA})

EMA_30.30 = EMA_30.30 %>% 
  mutate(Mean_PC_klass = case_when(
    Mean_PC <= -50 ~ -2,
    Mean_PC > -50 & Mean_PC <= -25 ~ -1,
    Mean_PC > -25 & Mean_PC < 25 ~ 0,
    Mean_PC >= 25 & Mean_PC < 50 ~ 1,
    Mean_PC >= 50 ~ 2,
    TRUE ~ Mean_PC
  )
)


temp = EMA_30.30 %>% 
  dplyr::count(Mean_PC_klass) %>% 
  mutate(Percentage = round(((n / sum(n)) * 100), digits = 2))

PC_Int %>%
  dplyr::rename(Mean_PC_klass = Klassifikation) %>%
  full_join(., temp) %>% 
  kable() %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = FALSE)
PC Mean_PC_klass Interpretation n Percentage
PC <= -50 -2 starke Verschlechterung NA NA
-50 < PC <= -25 -1 Verschlechterung 4 8
-25 < PC < 25 0 keine Veränderung 21 42
25 <= PC < 50 1 Verbesserung 13 26
PC >= 50 2 starke Verbesserung 12 24
scatter.hist(EMA_30.30$PRE_Mean, EMA_30.30$Mean_PC, xlab = "EMA_30.30$PRE_Mean", ylab = "EMA_30.30$Mean_PC", ellipse = FALSE, grid = TRUE, col = c("dodgerblue", "darkorange"))

Korrelation Mean Percentage Change (je 30 MZP) mit PHQ-Baseline (Pre-Intervall-Mean) = 0.566.


1.7.2 EMA_5.5_Window

EMA_5.5_Window$Mean_PC = (1-(EMA_5.5_Window$POST_Mean / EMA_5.5_Window$PRE_Mean)) * 100

# Sollen Mean_PC %in% c(-Inf,Inf) ein-/ausgeschlossen werden?
#EMA_5.5_Window = EMA_5.5_Window %>% 
#  within(., {Mean_PC[Mean_PC %in% c(-Inf,Inf)] = NA})

EMA_5.5_Window = EMA_5.5_Window %>% 
  mutate(Mean_PC_klass = case_when(
    Mean_PC <= -50 ~ -2,
    Mean_PC > -50 & Mean_PC <= -25 ~ -1,
    Mean_PC > -25 & Mean_PC < 25 ~ 0,
    Mean_PC >= 25 & Mean_PC < 50 ~ 1,
    Mean_PC >= 50 ~ 2,
    TRUE ~ Mean_PC
  )
)


temp = EMA_5.5_Window %>% 
  dplyr::count(Mean_PC_klass) %>% 
  mutate(Percentage = round(((n / sum(n)) * 100), digits = 2))

PC_Int %>%
  dplyr::rename(Mean_PC_klass = Klassifikation) %>%
  full_join(., temp) %>% 
  kable() %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = FALSE)
PC Mean_PC_klass Interpretation n Percentage
PC <= -50 -2 starke Verschlechterung 1 2
-50 < PC <= -25 -1 Verschlechterung 1 2
-25 < PC < 25 0 keine Veränderung 24 48
25 <= PC < 50 1 Verbesserung 11 22
PC >= 50 2 starke Verbesserung 13 26
scatter.hist(EMA_5.5_Window$PRE_Mean, EMA_5.5_Window$Mean_PC, xlab = "EMA_5.5_Window$PRE_Mean", ylab = "EMA_5.5_Window$Mean_PC", ellipse = FALSE, grid = TRUE, col = c("dodgerblue", "darkorange"))

Korrelation Mean Percentage Change (je 5 MZP) mit PHQ-Baseline (Pre-Intervall-Mean) = 0.522.


1.7.3 EMA_5.5_Days

EMA_5.5_Days$Mean_PC = (1-(EMA_5.5_Days$POST_Mean / EMA_5.5_Days$PRE_Mean)) * 100

# Sollen Mean_PC %in% c(-Inf,Inf) ein-/ausgeschlossen werden?
#EMA_5.5_Days = EMA_5.5_Days %>% 
#  within(., {Mean_PC[Mean_PC %in% c(-Inf,Inf)] = NA})

EMA_5.5_Days = EMA_5.5_Days %>% 
  mutate(Mean_PC_klass = case_when(
    Mean_PC <= -50 ~ -2,
    Mean_PC > -50 & Mean_PC <= -25 ~ -1,
    Mean_PC > -25 & Mean_PC < 25 ~ 0,
    Mean_PC >= 25 & Mean_PC < 50 ~ 1,
    Mean_PC >= 50 ~ 2,
    TRUE ~ Mean_PC
  )
)


temp = EMA_5.5_Days %>% 
  dplyr::count(Mean_PC_klass) %>% 
  mutate(Percentage = round(((n / sum(n)) * 100), digits = 2))

PC_Int %>%
  dplyr::rename(Mean_PC_klass = Klassifikation) %>%
  full_join(., temp) %>% 
  kable() %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = FALSE)
PC Mean_PC_klass Interpretation n Percentage
PC <= -50 -2 starke Verschlechterung 2 4
-50 < PC <= -25 -1 Verschlechterung 7 14
-25 < PC < 25 0 keine Veränderung 15 30
25 <= PC < 50 1 Verbesserung 10 20
PC >= 50 2 starke Verbesserung 16 32
scatter.hist(EMA_5.5_Days$PRE_Mean, EMA_5.5_Days$Mean_PC, xlab = "EMA_5.5_Days$PRE_Mean", ylab = "EMA_5.5_Days$Mean_PC", ellipse = FALSE, grid = TRUE, col = c("dodgerblue", "darkorange"))

Korrelation Mean Percentage Change (je 5 MZP) mit PHQ-Baseline (Pre-Intervall-Mean) = 0.669.


1.7.4 Zusammenhang im Scatter-Histogramm

scatter.hist(EMA_30.30$Mean_PC, EMA_5.5_Window$Mean_PC, xlab = "EMA_30.30$Mean_PC", ylab = "EMA_5.5_Window$Mean_PC", ellipse = FALSE, grid = TRUE, col = c("dodgerblue", "darkorange"))

scatter.hist(EMA_30.30$Mean_PC, EMA_5.5_Days$Mean_PC, xlab = "EMA_30.30$Mean_PC", ylab = "EMA_5.5_Days$Mean_PC", ellipse = FALSE, grid = TRUE, col = c("dodgerblue", "darkorange"))

scatter.hist(EMA_5.5_Window$Mean_PC, EMA_5.5_Days$Mean_PC, xlab = "EMA_5.5_Window$Mean_PC", ylab = "EMA_5.5_Days$Mean_PC", ellipse = FALSE, grid = TRUE, col = c("dodgerblue", "darkorange"))


1.8 Individual Reliable Change Index (ind)

1.8.1 RCI(ind) nur mit SD aus dem individuellen Pre-Intervall


\[ RCI_{ind,preSD} = \frac{\overline{x_{2}} - \overline{x_{1}}} {SE_{D,pre}} \]

\[ SE_{D,pre} = \sqrt{2 \cdot (s_{x} \cdot (1 - r_{xy})^2)} \]

\[ \text{significance cutoff} = 1.96 \cdot SE_{D,pre} = 1.96 \cdot \sqrt{2 \cdot (s_{x} \cdot (1 - r_{xy})^2)} \]

\(\overline{x_{2}}\) = mean of subject´s posttest scores, \(\overline{x_{1}}\) = mean of subject´s pretest scores, \(SE_{D,pre}\) = standard error of difference between the test scores in the individual´s pre interval \(s_{x}\) = individual standard deviation of pretest time points, \(r_{xy}\) = reliability (internal consistency Cronbach´s \(\alpha\)) of the measure, \(\text{significance cutoff}\) = (absolute) cutoff score for reliable change (95%-criterion)

EMA_30.30

EMA_30.30$SEd_pre = sqrt(2 * (EMA_30.30$ind.pretestSD * sqrt(1 - EMA_5.5_Alpha)) ^ 2)
EMA_30.30$RCI_ind_preSD = (EMA_30.30$POST_Mean - EMA_30.30$PRE_Mean) / EMA_30.30$SEd_pre
EMA_30.30$RCI_ind_preSD_Cutoff =  1.96 * EMA_30.30$SEd_pre

# Sollen SEd_pre, RCI_ind_preSD und RCI_ind_preSD_Cutoff %in% c(-Inf,Inf) ein-/ausgeschlossen werden?
#EMA_30.30 = EMA_30.30 %>% 
#  within(., {SEd_pre[SEd_pre %in% c(-Inf,Inf)] = NA
#               RCI_ind_preSD[RCI_ind_preSD %in% c(-Inf,Inf)] = NA
#               RCI_ind_preSD_Cutoff[RCI_ind_preSD_Cutoff %in% c(-Inf,Inf)] = NA})

scatter.hist(EMA_30.30$PRE_Mean, EMA_30.30$RCI_ind_preSD, xlab = "EMA_30.30$PRE_Mean", ylab = "EMA_30.30$RCI_ind_preSD", ellipse = FALSE, grid = TRUE, col = c("dodgerblue", "darkorange"))

Durchschnittlicher RCI(ind)-Cutoff für reliable Veränderung in EMA_30.30 = 4.
Korrelation RCI(ind) nur mit Pre-SD (je 30 MZP) mit PHQ-Baseline (Pre-Intervall-Mean) = -0.619.

EMA_5.5_Window

EMA_5.5_Window$SEd_pre = sqrt(2 * (EMA_5.5_Window$ind.pretestSD * sqrt(1 - EMA_5.5_Alpha)) ^ 2)
EMA_5.5_Window$RCI_ind_preSD = (EMA_5.5_Window$POST_Mean - EMA_5.5_Window$PRE_Mean) / EMA_5.5_Window$SEd_pre
EMA_5.5_Window$RCI_ind_preSD_Cutoff =  1.96 * EMA_5.5_Window$SEd_pre

# Sollen SEd_pre, RCI_ind_preSD und RCI_ind_preSD_Cutoff %in% c(-Inf,Inf) ein-/ausgeschlossen werden?
#EMA_5.5_Window = EMA_5.5_Window %>% 
#  within(., {SEd_pre[SEd_pre %in% c(-Inf,Inf)] = NA
#               RCI_ind_preSD[RCI_ind_preSD %in% c(-Inf,Inf)] = NA
#               RCI_ind_preSD_Cutoff[RCI_ind_preSD_Cutoff %in% c(-Inf,Inf)] = NA})

scatter.hist(EMA_5.5_Window$PRE_Mean, EMA_5.5_Window$RCI_ind_preSD, xlab = "EMA_5.5_Window$PRE_Mean", ylab = "EMA_5.5_Window$RCI_ind_preSD", ellipse = FALSE, grid = TRUE, col = c("dodgerblue", "darkorange"))

Durchschnittlicher RCI(ind)-Cutoff für reliable Veränderung in EMA_5.5_Window = 3.999.
Korrelation RCI(ind) nur mit Pre-SD (je 5 MZP) mit PHQ-Baseline (Pre-Intervall-Mean) = -0.608.

EMA_5.5_Days

EMA_5.5_Days$SEd_pre = sqrt(2 * (EMA_5.5_Days$ind.pretestSD * sqrt(1 - EMA_5.5_Alpha)) ^ 2)
EMA_5.5_Days$RCI_ind_preSD = (EMA_5.5_Days$POST_Mean - EMA_5.5_Days$PRE_Mean) / EMA_5.5_Days$SEd_pre
EMA_5.5_Days$RCI_ind_preSD_Cutoff =  1.96 * EMA_5.5_Days$SEd_pre

# Sollen SEd_pre, RCI_ind_preSD und RCI_ind_preSD_Cutoff %in% c(-Inf,Inf) ein-/ausgeschlossen werden?
#EMA_5.5_Days = EMA_5.5_Days %>% 
#  within(., {SEd_pre[SEd_pre %in% c(-Inf,Inf)] = NA
#               RCI_ind_preSD[RCI_ind_preSD %in% c(-Inf,Inf)] = NA
#               RCI_ind_preSD_Cutoff[RCI_ind_preSD_Cutoff %in% c(-Inf,Inf)] = NA})

scatter.hist(EMA_5.5_Days$PRE_Mean, EMA_5.5_Days$RCI_ind_preSD, xlab = "EMA_5.5_Days$PRE_Mean", ylab = "EMA_5.5_Days$RCI_ind_preSD", ellipse = FALSE, grid = TRUE, col = c("dodgerblue", "darkorange"))

Durchschnittlicher RCI(ind)-Cutoff für reliable Veränderung in EMA_5.5_Days = 4.077.
Korrelation RCI(ind) nur mit Pre-SD (je 5 MZP) mit PHQ-Baseline (Pre-Intervall-Mean) = -0.624.


1.8.2 RCI(ind) mit pooled SD aus beiden individuellen Intervallen


\[ RCI_{ind} = \frac{\overline{x_{2}} - \overline{x_{1}}} {SE_{D}} \]

\[ SE_{D} = \sqrt{(s_{x}^2 + s_{y}^2) \cdot (1 - r_{xy})} \]

\[ \text{significance cutoff} = 1.96 \cdot SE_{D} = 1.96 \cdot \sqrt{(s_{x}^2 + s_{y}^2) \cdot (1 - r_{xy})} \]

\(\overline{x_{2}}\) = mean of subject´s posttest scores, \(\overline{x_{1}}\) = mean of subject´s pretest scores, \(SE_{D}\) = pooled standard error of difference between the test scores \(s_{x}\) = individual standard deviation of pretest time points, \(s_{y}\) = individual standard deviation of pretest time points, \(r_{xy}\) = reliability (internal consistency Cronbach´s \(\alpha\)) of the measure, \(\text{significance cutoff}\) = (absolute) cutoff score for reliable change (95%-criterion)

EMA_30.30

EMA_30.30$SEd_pooled = sqrt((EMA_30.30$ind.pretestSD ^ 2 + EMA_30.30$ind.posttestSD ^ 2) * (1 - EMA_5.5_Alpha))
EMA_30.30$RCI_ind_pooledSD = (EMA_30.30$POST_Mean - EMA_30.30$PRE_Mean) / EMA_30.30$SEd_pooled
EMA_30.30$RCI_ind_pooledSD_Cutoff =  1.96 * EMA_30.30$SEd_pooled

# Sollen SEd_pooled, RCI_ind_pooledSD und RCI_ind_pooledSD_Cutoff %in% c(-Inf,Inf) ein-/ausgeschlossen werden?
#EMA_30.30 = EMA_30.30 %>% 
#  within(., {SEd_pooled[SEd_pooled %in% c(-Inf,Inf)] = NA
#               RCI_ind_pooledSD[RCI_ind_pooledSD %in% c(-Inf,Inf)] = NA
#               RCI_ind_pooledSD_Cutoff[RCI_ind_pooledSD_Cutoff %in% c(-Inf,Inf)] = NA})

scatter.hist(EMA_30.30$PRE_Mean, EMA_30.30$RCI_ind_pooledSD, xlab = "EMA_30.30$PRE_Mean", ylab = "EMA_30.30$RCI_ind_pooledSD", ellipse = FALSE, grid = TRUE, col = c("dodgerblue", "darkorange"))

Durchschnittlicher RCI(ind)-Cutoff für reliable Veränderung in EMA_30.30 = 5.23.
Korrelation RCI(ind) mit pooled SDs (je 30 MZP) mit PHQ-Baseline (Pre-Intervall-Mean) = -0.585.

EMA_5.5_Window

EMA_5.5_Window$SEd_pooled = sqrt((EMA_5.5_Window$ind.pretestSD ^ 2 + EMA_5.5_Window$ind.posttestSD ^ 2) * (1 - EMA_5.5_Alpha))
EMA_5.5_Window$RCI_ind_pooledSD = (EMA_5.5_Window$POST_Mean - EMA_5.5_Window$PRE_Mean) / EMA_5.5_Window$SEd_pooled
EMA_5.5_Window$RCI_ind_pooledSD_Cutoff =  1.96 * EMA_5.5_Window$SEd_pooled

# Sollen SEd_pooled, RCI_ind_pooledSD und RCI_ind_pooledSD_Cutoff %in% c(-Inf,Inf) ein-/ausgeschlossen werden?
#EMA_5.5_Window = EMA_5.5_Window %>% 
#  within(., {SEd_pooled[SEd_pooled %in% c(-Inf,Inf)] = NA
#               RCI_ind_pooledSD[RCI_ind_pooledSD %in% c(-Inf,Inf)] = NA
#               RCI_ind_pooledSD_Cutoff[RCI_ind_pooledSD_Cutoff %in% c(-Inf,Inf)] = NA})

scatter.hist(EMA_5.5_Window$PRE_Mean, EMA_5.5_Window$RCI_ind_pooledSD, xlab = "EMA_5.5_Window$PRE_Mean", ylab = "EMA_5.5_Window$RCI_ind_pooledSD", ellipse = FALSE, grid = TRUE, col = c("dodgerblue", "darkorange"))

Durchschnittlicher RCI(ind)-Cutoff für reliable Veränderung in EMA_5.5_Window = 5.289.
Korrelation RCI(ind) mit pooled SDs (je 5 MZP) mit PHQ-Baseline (Pre-Intervall-Mean) = -0.586.

EMA_5.5_Days

EMA_5.5_Days$SEd_pooled = sqrt((EMA_5.5_Days$ind.pretestSD ^ 2 + EMA_5.5_Days$ind.posttestSD ^ 2) * (1 - EMA_5.5_Alpha))
EMA_5.5_Days$RCI_ind_pooledSD = (EMA_5.5_Days$POST_Mean - EMA_5.5_Days$PRE_Mean) / EMA_5.5_Days$SEd_pooled
EMA_5.5_Days$RCI_ind_pooledSD_Cutoff =  1.96 * EMA_5.5_Days$SEd_pooled

# Sollen SEd_pooled, RCI_ind_pooledSD und RCI_ind_pooledSD_Cutoff %in% c(-Inf,Inf) ein-/ausgeschlossen werden?
#EMA_5.5_Days = EMA_5.5_Days %>% 
#  within(., {SEd_pooled[SEd_pooled %in% c(-Inf,Inf)] = NA
#               RCI_ind_pooledSD[RCI_ind_pooledSD %in% c(-Inf,Inf)] = NA
#               RCI_ind_pooledSD_Cutoff[RCI_ind_pooledSD_Cutoff %in% c(-Inf,Inf)] = NA})

scatter.hist(EMA_5.5_Days$PRE_Mean, EMA_5.5_Days$RCI_ind_pooledSD, xlab = "EMA_5.5_Days$PRE_Mean", ylab = "EMA_5.5_Days$RCI_ind_pooledSD", ellipse = FALSE, grid = TRUE, col = c("dodgerblue", "darkorange"))

Durchschnittlicher RCI(ind)-Cutoff für reliable Veränderung in EMA_5.5_Days = 5.277.
Korrelation RCI(ind) mit pooled SDs (je 5 MZP) mit PHQ-Baseline (Pre-Intervall-Mean) = -0.671.


1.9 Vergleich RCI(ind) (nur Pre-SD) - RCI(ind) (pooled SDs)

scatter.hist(EMA_30.30$RCI_ind_preSD, EMA_30.30$RCI_ind_pooledSD, xlab = "EMA_30.30$RCI_ind_preSD", ylab =
               "EMA_30.30$RCI_ind_pooledSD", ellipse = FALSE, grid = TRUE, col = c("dodgerblue",  "darkorange"))

scatter.hist(EMA_5.5_Window$RCI_ind_preSD, EMA_5.5_Window$RCI_ind_pooledSD, xlab = "EMA_5.5_Window$RCI_ind_preSD", ylab =
               "EMA_5.5_Window$RCI_ind_pooledSD", ellipse = FALSE, grid = TRUE, col = c("dodgerblue",  "darkorange"))

scatter.hist(EMA_5.5_Days$RCI_ind_preSD, EMA_5.5_Days$RCI_ind_pooledSD, xlab = "EMA_5.5_Days$RCI_ind_preSD", ylab =
               "EMA_5.5_Days$RCI_ind_pooledSD", ellipse = FALSE, grid = TRUE, col = c("dodgerblue",  "darkorange"))


1.10 RCI-Klassifikationen

RCI_Int = tibble(RCI = c("RCI < -1,96","-1,96 <= RCI <= 1,96","RCI > 1,96"),
                Klassifikation = c(-1,0,1),
                Interpretation = c("reliable Verbesserung","keine reliable Veränderung","reliable Verschlechterung"))

EMA_30.30: RCI(ind) nur mit Pre-SDs

EMA_30.30 = EMA_30.30 %>% 
  mutate(RCI_ind_preSD_klass = case_when(
    RCI_ind_preSD < -1.96 ~ -1,
    RCI_ind_preSD >= -1.96 & RCI_ind_preSD < 1.96 ~ 0,
    RCI_ind_preSD > 1.96 ~ 1,
    TRUE ~ RCI_ind_preSD
  )
)

temp = EMA_30.30 %>% 
  count(RCI_ind_preSD_klass) %>% 
  mutate(Percentage = round(((n / sum(n)) * 100), digits = 2))

RCI_Int %>%
  dplyr::rename(RCI_ind_preSD_klass = Klassifikation) %>%
  full_join(., temp) %>% 
  kable() %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = FALSE)
RCI RCI_ind_preSD_klass Interpretation n Percentage
RCI < -1,96 -1 reliable Verbesserung 21 42
-1,96 <= RCI <= 1,96 0 keine reliable Veränderung 29 58
RCI > 1,96 1 reliable Verschlechterung NA NA

EMA_30.30: RCI(ind) mit pooled SDs

EMA_30.30 = EMA_30.30 %>% 
  mutate(RCI_ind_pooledSD_klass = case_when(
    RCI_ind_pooledSD < -1.96 ~ -1,
    RCI_ind_pooledSD >= -1.96 & RCI_ind_pooledSD < 1.96 ~ 0,
    RCI_ind_pooledSD > 1.96 ~ 1,
    TRUE ~ RCI_ind_pooledSD
  )
)

temp = EMA_30.30 %>% 
  count(RCI_ind_pooledSD_klass) %>% 
  mutate(Percentage = round(((n / sum(n)) * 100), digits = 2))

RCI_Int %>%
  dplyr::rename(RCI_ind_pooledSD_klass = Klassifikation) %>%
  full_join(., temp) %>% 
  kable() %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = FALSE)
RCI RCI_ind_pooledSD_klass Interpretation n Percentage
RCI < -1,96 -1 reliable Verbesserung 15 30
-1,96 <= RCI <= 1,96 0 keine reliable Veränderung 35 70
RCI > 1,96 1 reliable Verschlechterung NA NA

EMA_5.5_Window: RCI(ind) nur mit Pre-SDs

EMA_5.5_Window = EMA_5.5_Window %>% 
  mutate(RCI_ind_preSD_klass = case_when(
    RCI_ind_preSD < -1.96 ~ -1,
    RCI_ind_preSD >= -1.96 & RCI_ind_preSD < 1.96 ~ 0,
    RCI_ind_preSD > 1.96 ~ 1,
    TRUE ~ RCI_ind_preSD
  )
)

temp = EMA_5.5_Window %>% 
  count(RCI_ind_preSD_klass) %>% 
  mutate(Percentage = round(((n / sum(n)) * 100), digits = 2))

RCI_Int %>%
  dplyr::rename(RCI_ind_preSD_klass = Klassifikation) %>%
  full_join(., temp) %>% 
  kable() %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = FALSE)
RCI RCI_ind_preSD_klass Interpretation n Percentage
RCI < -1,96 -1 reliable Verbesserung 21 42
-1,96 <= RCI <= 1,96 0 keine reliable Veränderung 29 58
RCI > 1,96 1 reliable Verschlechterung NA NA

EMA_5.5_Window: RCI(ind) mit pooled SDs

EMA_5.5_Window = EMA_5.5_Window %>% 
  mutate(RCI_ind_pooledSD_klass = case_when(
    RCI_ind_pooledSD < -1.96 ~ -1,
    RCI_ind_pooledSD >= -1.96 & RCI_ind_pooledSD < 1.96 ~ 0,
    RCI_ind_pooledSD > 1.96 ~ 1,
    TRUE ~ RCI_ind_pooledSD
  )
)

temp = EMA_5.5_Window %>% 
  count(RCI_ind_pooledSD_klass) %>% 
  mutate(Percentage = round(((n / sum(n)) * 100), digits = 2))

RCI_Int %>%
  dplyr::rename(RCI_ind_pooledSD_klass = Klassifikation) %>%
  full_join(., temp) %>% 
  kable() %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = FALSE)
RCI RCI_ind_pooledSD_klass Interpretation n Percentage
RCI < -1,96 -1 reliable Verbesserung 15 30
-1,96 <= RCI <= 1,96 0 keine reliable Veränderung 34 68
RCI > 1,96 1 reliable Verschlechterung 1 2

EMA_5.5_Days: RCI(ind) nur mit Pre-SDs

EMA_5.5_Days = EMA_5.5_Days %>% 
  mutate(RCI_ind_preSD_klass = case_when(
    RCI_ind_preSD < -1.96 ~ -1,
    RCI_ind_preSD >= -1.96 & RCI_ind_preSD < 1.96 ~ 0,
    RCI_ind_preSD > 1.96 ~ 1,
    TRUE ~ RCI_ind_preSD
  )
)

temp = EMA_5.5_Days %>% 
  count(RCI_ind_preSD_klass) %>% 
  mutate(Percentage = round(((n / sum(n)) * 100), digits = 2))

RCI_Int %>%
  dplyr::rename(RCI_ind_preSD_klass = Klassifikation) %>%
  full_join(., temp) %>% 
  kable() %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = FALSE)
RCI RCI_ind_preSD_klass Interpretation n Percentage
RCI < -1,96 -1 reliable Verbesserung 23 46
-1,96 <= RCI <= 1,96 0 keine reliable Veränderung 24 48
RCI > 1,96 1 reliable Verschlechterung 3 6

EMA_5.5_Days: RCI(ind) mit pooled SDs

EMA_5.5_Days = EMA_5.5_Days %>% 
  mutate(RCI_ind_pooledSD_klass = case_when(
    RCI_ind_pooledSD < -1.96 ~ -1,
    RCI_ind_pooledSD >= -1.96 & RCI_ind_pooledSD < 1.96 ~ 0,
    RCI_ind_pooledSD > 1.96 ~ 1,
    TRUE ~ RCI_ind_pooledSD
  )
)

temp = EMA_5.5_Days %>% 
  count(RCI_ind_pooledSD_klass) %>% 
  mutate(Percentage = round(((n / sum(n)) * 100), digits = 2))

RCI_Int %>%
  dplyr::rename(RCI_ind_pooledSD_klass = Klassifikation) %>%
  full_join(., temp) %>% 
  kable() %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = FALSE)
RCI RCI_ind_pooledSD_klass Interpretation n Percentage
RCI < -1,96 -1 reliable Verbesserung 18 36
-1,96 <= RCI <= 1,96 0 keine reliable Veränderung 30 60
RCI > 1,96 1 reliable Verschlechterung 2 4

1.11 Edwards-Nunnally-Methode (EN) nach Speer (1992)


\[ \bigl[ r_{xx} (X_{pre} - M_{pre}) + M_{pre} \bigr] \pm 2 \cdot S_{pre} \cdot \sqrt{1 - r_{xx}} \]

\(r_{xx}\) = reliability of the measure, \(X_{pre}\) = individual´s raw score at pre-treatment, \(M_{pre}\) = mean of the sample at pre-treatment, \(S_{pre}\) = standard deviation of the sample at pre-treatment

Interpretation der Post-Ausprägung nach EN-Intervall-Methode

EN_Int = tibble(EN = c("PHQ POST < [EN-Intervall]","PHQ POST im [EN-Intervall]","PHQ POST > [EN-Intervall]"),
                Klassifikation = c(-1,0,1), Interpretation = c("signifikante Verbesserung",
                        "keine signifikante Veränderung","signifikante Verschlechterung"))

EN-Intervalle in EMA_30.30

EMA_30.30$EN_min = (EMA_5.5_Alpha * (EMA_30.30$PRE_Mean - mean(EMA_30.30$PRE_Mean)) + mean(EMA_30.30$PRE_Mean)) - 2 * mean(EMA_30.30$ind.pretestSD) * sqrt(1 - EMA_5.5_Alpha)

EMA_30.30$EN_max = (EMA_5.5_Alpha * (EMA_30.30$PRE_Mean - mean(EMA_30.30$PRE_Mean)) + mean(EMA_30.30$PRE_Mean)) + 2 * mean(EMA_30.30$ind.pretestSD) * sqrt(1 - EMA_5.5_Alpha)

EMA_30.30 = EMA_30.30 %>% 
  mutate(EN_klass = case_when(
    POST_Mean > EN_max ~ 1,
    POST_Mean < EN_max & POST_Mean > EN_min ~ 0,
    POST_Mean < EN_min ~ -1,
    TRUE ~ POST_Mean
  )
)

temp = EMA_30.30 %>% 
  count(EN_klass) %>% 
  mutate(Percentage = round(((n / sum(n)) * 100), digits = 2))

EN_Int %>%
  dplyr::rename(EN_klass = Klassifikation) %>%
  full_join(., temp) %>% 
  kable() %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = FALSE)
EN EN_klass Interpretation n Percentage
PHQ POST < [EN-Intervall] -1 signifikante Verbesserung 24 48
PHQ POST im [EN-Intervall] 0 keine signifikante Veränderung 26 52
PHQ POST > [EN-Intervall] 1 signifikante Verschlechterung NA NA

EN-Intervalle in EMA_5.5_Window

EMA_5.5_Window$EN_min = (EMA_5.5_Alpha * (EMA_5.5_Window$PRE_Mean - mean(EMA_5.5_Window$PRE_Mean)) + 
                           mean(EMA_5.5_Window$PRE_Mean)) - 2 *  mean(EMA_5.5_Window$ind.pretestSD) * sqrt(1 - EMA_5.5_Alpha)

EMA_5.5_Window$EN_max = (EMA_5.5_Alpha * (EMA_5.5_Window$PRE_Mean - mean(EMA_5.5_Window$PRE_Mean)) + 
                           mean(EMA_5.5_Window$PRE_Mean)) + 2 * mean(EMA_5.5_Window$ind.pretestSD) * sqrt(1 - EMA_5.5_Alpha)

EMA_5.5_Window = EMA_5.5_Window %>% 
  mutate(EN_klass = case_when(
    POST_Mean > EN_max ~ 1,
    POST_Mean < EN_max & POST_Mean > EN_min ~ 0,
    POST_Mean < EN_min ~ -1,
    TRUE ~ POST_Mean
  )
)

temp = EMA_5.5_Window %>% 
  count(EN_klass) %>% 
  mutate(Percentage = round(((n / sum(n)) * 100), digits = 2))

EN_Int %>%
  dplyr::rename(EN_klass = Klassifikation) %>%
  full_join(., temp) %>% 
  kable() %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = FALSE)
EN EN_klass Interpretation n Percentage
PHQ POST < [EN-Intervall] -1 signifikante Verbesserung 24 48
PHQ POST im [EN-Intervall] 0 keine signifikante Veränderung 25 50
PHQ POST > [EN-Intervall] 1 signifikante Verschlechterung 1 2

EN-Intervalle in EMA_5.5_Days

EMA_5.5_Days$EN_min = (EMA_5.5_Alpha * (EMA_5.5_Days$PRE_Mean - mean(EMA_5.5_Days$PRE_Mean)) + 
                           mean(EMA_5.5_Days$PRE_Mean)) - 2 *  mean(EMA_5.5_Days$ind.pretestSD) * sqrt(1 - EMA_5.5_Alpha)

EMA_5.5_Days$EN_max = (EMA_5.5_Alpha * (EMA_5.5_Days$PRE_Mean - mean(EMA_5.5_Days$PRE_Mean)) + 
                           mean(EMA_5.5_Days$PRE_Mean)) + 2 * mean(EMA_5.5_Days$ind.pretestSD) * sqrt(1 - EMA_5.5_Alpha)

EMA_5.5_Days = EMA_5.5_Days %>% 
  mutate(EN_klass = case_when(
    POST_Mean > EN_max ~ 1,
    POST_Mean < EN_max & POST_Mean > EN_min ~ 0,
    POST_Mean < EN_min ~ -1,
    TRUE ~ POST_Mean
  )
)

temp = EMA_5.5_Days %>% 
  count(EN_klass) %>% 
  mutate(Percentage = round(((n / sum(n)) * 100), digits = 2))

EN_Int %>%
  dplyr::rename(EN_klass = Klassifikation) %>%
  full_join(., temp) %>% 
  kable() %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = FALSE)
EN EN_klass Interpretation n Percentage
PHQ POST < [EN-Intervall] -1 signifikante Verbesserung 25 50
PHQ POST im [EN-Intervall] 0 keine signifikante Veränderung 23 46
PHQ POST > [EN-Intervall] 1 signifikante Verschlechterung 2 4

1.12 Clinically Significant Improvement (CSI)

Clinically Significant Improvement (CSI) vom Pre- zum Post-Intervall

“The original validation study of the PHQ-9 defined clinically significant improvement as [a pre-treatment score >= 10 and] a post-treatment score of <= 9 combined with improvement of 50%.” (McMillan, Gilbody, & Richards, 2010)

CSI_Int = tibble(CSI = c("Pre-Score >= 10 & Post-Score <= 9 & PC >= 50", "every other combination", 
                         "Pre-Score <= 9 & Post-Score >= 10 & PC <= -50"),
                Klassifikation = c(-1,0,1),
                Interpretation = c("klinisch signifikante Verbesserung", "keine klinisch signifikante Veränderung", 
                                   "klinisch signifikante Verschlechterung"))

1.12.1 CSI in EMA_30.30

EMA_30.30 = EMA_30.30 %>% 
   mutate(CSI_klass = case_when(
     PRE_Mean >= 10 & POST_Mean <= 9 & Mean_PC >= 50 ~ -1,
     PRE_Mean <= 9 & POST_Mean >= 10 & Mean_PC <= -50 ~ 1,
     TRUE ~ 0
   )
)

temp = EMA_30.30 %>% 
  count(CSI_klass) %>% 
  mutate(Percentage = round(((n / sum(n)) * 100), digits = 2))

CSI_Int %>%
  dplyr::rename(CSI_klass = Klassifikation) %>%
  full_join(., temp) %>% 
  kable() %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = FALSE)
CSI CSI_klass Interpretation n Percentage
Pre-Score >= 10 & Post-Score <= 9 & PC >= 50 -1 klinisch signifikante Verbesserung 9 18
every other combination 0 keine klinisch signifikante Veränderung 41 82
Pre-Score <= 9 & Post-Score >= 10 & PC <= -50 1 klinisch signifikante Verschlechterung NA NA

1.12.2 CSI in EMA_5.5_Window

EMA_5.5_Window = EMA_5.5_Window %>% 
   mutate(CSI_klass = case_when(
     PRE_Mean >= 10 & POST_Mean <= 9 & Mean_PC >= 50 ~ -1,
     PRE_Mean <= 9 & POST_Mean >= 10 & Mean_PC <= -50 ~ 1,
     TRUE ~ 0
   )
)

temp = EMA_5.5_Window %>% 
  count(CSI_klass) %>% 
  mutate(Percentage = round(((n / sum(n)) * 100), digits = 2))

CSI_Int %>%
  dplyr::rename(CSI_klass = Klassifikation) %>%
  full_join(., temp) %>% 
  kable() %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = FALSE)
CSI CSI_klass Interpretation n Percentage
Pre-Score >= 10 & Post-Score <= 9 & PC >= 50 -1 klinisch signifikante Verbesserung 12 24
every other combination 0 keine klinisch signifikante Veränderung 37 74
Pre-Score <= 9 & Post-Score >= 10 & PC <= -50 1 klinisch signifikante Verschlechterung 1 2

1.12.3 CSI in EMA_5.5_Days

EMA_5.5_Days = EMA_5.5_Days %>% 
   mutate(CSI_klass = case_when(
     PRE_Mean >= 10 & POST_Mean <= 9 & Mean_PC >= 50 ~ -1,
     PRE_Mean <= 9 & POST_Mean >= 10 & Mean_PC <= -50 ~ 1,
     TRUE ~ 0
   )
)

temp = EMA_5.5_Days %>% 
  count(CSI_klass) %>% 
  mutate(Percentage = round(((n / sum(n)) * 100), digits = 2))

CSI_Int %>%
  dplyr::rename(CSI_klass = Klassifikation) %>%
  full_join(., temp) %>% 
  kable() %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = FALSE)
CSI CSI_klass Interpretation n Percentage
Pre-Score >= 10 & Post-Score <= 9 & PC >= 50 -1 klinisch signifikante Verbesserung 12 24
every other combination 0 keine klinisch signifikante Veränderung 36 72
Pre-Score <= 9 & Post-Score >= 10 & PC <= -50 1 klinisch signifikante Verschlechterung 2 4

1.13 Sudden Gains

Sudden Gain/Loss-Klassifikation vom Pre- zum Post-Intervall mithilfe des R-Packages “suddengains”

3 Kriterien nach Tang & DeRubeis (1999): bedeutende absolute Veränderung: Über-/Unterschreitung eines definierten Cutoff-Scores (z.B. RCI), hier PHQ-9-Score <= 9 bedeutende relative Veränderung: Reduktion/Zuwachs von Pre zu Post um >= 25% bedeutende Veränderung relativ zur Symptom-Fluktuation:

\[ M_{pre} - M_{post} > \text{critical value} \cdot \sqrt{\frac{\left(n_{pre} - 1 \right) \cdot SD^2_{pre} + \left(n_{post} - 1 \right) \cdot SD^2_{post}} {n_{pre} + n_{post} - 2}} \]

\(M_{pre}\) = mean of the subject´s scores before a potential gain/loss, \(M_{post}\) = mean of the subject´s scores after a potential gain/loss, \(\text{critical value}\) = 2.776 = two-tailed t statistic for \(\alpha\) = 0.05 and df = 4, \(n_{pre}\) = number of measurement points before a potential gain/loss, \(n_{post}\) = number of measurement points after a potential gain/loss, \(SD^2_{pre}\) = standard deviation of the subject´s scores before a potential gain/loss, \(SD^2_{post}\) = standard deviation of the subject´s scores after a potential gain/loss

SG_Int = tibble(SG = c("PHQ-9 Post-Mean <= 9 & (Mean) PC >= 25 & Mean Diff. > (absolute) critical fluctuation", 
                       "every other combination of conditions", 
                       "PHQ-9 Post-Mean > 9 & (Mean) PC <= -25 & Mean Diff. > (absolute) critical fluctuation"),
                Klassifikation = c(-1,0,1),
                Interpretation = c("sudden gain", "no sudden change", "sudden loss"))

1.13.1 Sudden Gains/Losses in EMA_30.30

1.13.2 Sudden Gains/Losses in EMA_5.5_Window

1.13.3 Sudden Gains/Losses in EMA_5.5_Days


1.14 Individuelle Übereinstimmung der Klassifikationen

Übereinstimmung der Klassifikationen auf individueller Ebene zwischen EMA_30.30, EMA_5.5_Window und EMA_5.5_Days

Interpretation von Cohen´s Kappa:

tibble(Cohen_Kappa = c("k < .20",".21 <= k < .40",".41 <= k < .60",".61 <= k < .80","k > .80"),
       Interpretation = c("poor","fair","moderate","good","very good")) %>% 
  kable() %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = FALSE)
Cohen_Kappa Interpretation
k < .20 poor
.21 <= k < .40 fair
.41 <= k < .60 moderate
.61 <= k < .80 good
k > .80 very good

1.14.1 Klinische PHQ-9-Interpretation

Übereinstimmung zwischen den klinischen Interpretationen der PHQ-9-Werte für Pre- und Post-Intervalle (je 30 MZP und je 5 MZP):

# PRE
x = EMA_30.30 %>% 
  select(ID, PRE_Mean_klass) %>% 
  dplyr::rename(PRE_klass_30.30 = PRE_Mean_klass)

y = EMA_5.5_Window %>% 
  select(ID, PRE_Mean_klass) %>% 
  dplyr::rename(PRE_klass_5.5_Window = PRE_Mean_klass)

z = EMA_5.5_Days %>% 
  select(ID, PRE_Mean_klass) %>% 
  dplyr::rename(PRE_klass_5.5_Days = PRE_Mean_klass)

temp = full_join(x, y, by = "ID") %>% 
  full_join(., z, by = "ID") %>% 
  select(-ID) %>% 
  mutate(across(.cols = everything(), as.factor))

### Cohen´s Kappa
rnames = c("PRE_klass_30.30", "PRE_klass_5.5_Window", "PRE_klass_5.5_Days")

Agreement = matrix(ncol = 3, nrow = 3, dimnames = list(rnames, rnames))

for (i in 1:nrow(Agreement)) {
  for (j in 1:ncol(Agreement)) {
    x = eval(parse(text = paste0("temp$", names(temp[,i]))))
    y = eval(parse(text = paste0("temp$", names(temp[,j]))))
    
    Agreement[i,j] = CohenKappa(x = x, y = y)
  }
}

# mit plot.matrix::...
par(mar = c(5.1, 4.1, 4.1, 4.1)) # default c(5.1, 4.1, 4.1, 2.1)
plot(Agreement, col = heat.colors(n=5, rev=TRUE), fmt.cell = "%.2f", cex.axis = 0.7, cex = 0.8, las = 2, 
     key = list(cex.axis=0.7), ann = FALSE, breaks = c(0, 0.21, 0.41, 0.61, 0.81, 1));
  title(main = "Übereinstimmung (Cohen´s Kappa) der PHQ-PRE-Klassifikationen")

# POST
x = EMA_30.30 %>% 
  select(ID, POST_Mean_klass) %>% 
  dplyr::rename(POST_klass_30.30 = POST_Mean_klass)

y = EMA_5.5_Window %>% 
  select(ID, POST_Mean_klass) %>% 
  dplyr::rename(POST_klass_5.5_Window = POST_Mean_klass)

z = EMA_5.5_Days %>% 
  select(ID, POST_Mean_klass) %>% 
  dplyr::rename(POST_klass_5.5_Days = POST_Mean_klass)

temp = full_join(x, y, by = "ID") %>% 
  full_join(., z, by = "ID") %>% 
  select(-ID) %>% 
  mutate(across(.cols = everything(), as.factor))

### Cohen´s Kappa
rnames = c("POST_klass_30.30", "POST_klass_5.5_Window", "POST_klass_5.5_Days")

Agreement = matrix(ncol = 3, nrow = 3, dimnames = list(rnames, rnames))

for (i in 1:nrow(Agreement)) {
  for (j in 1:ncol(Agreement)) {
    x = eval(parse(text = paste0("temp$", names(temp[,i]))))
    y = eval(parse(text = paste0("temp$", names(temp[,j]))))
    
    Agreement[i,j] = CohenKappa(x = x, y = y)
  }
}

# mit plot.matrix::...
par(mar = c(5.1, 4.1, 4.1, 4.1)) # default c(5.1, 4.1, 4.1, 2.1)
plot(Agreement, col = heat.colors(n=5, rev=TRUE), fmt.cell = "%.2f", cex.axis = 0.7, cex = 0.8, las = 2, 
     key = list(cex.axis=0.7), ann = FALSE, breaks = c(0, 0.21, 0.41, 0.61, 0.81, 1));
  title(main = "Übereinstimmung (Cohen´s Kappa) der PHQ-POST-Klassifikationen")


1.14.2 Zusammenfassung der Klassifikations-Häufigkeiten

# einheitliche Kodierung von Verbesserung (-1), keiner Veränderung (0) und Verschlechterung (1):

x = EMA_30.30 %>% 
  select(ID, Mean_PC_klass, RCI_ind_preSD_klass, RCI_ind_pooledSD_klass, EN_klass, CSI_klass) %>% 
  dplyr::rename(Mean_PC_30.30 = Mean_PC_klass, RCI_ind_preSD_30.30 = RCI_ind_preSD_klass, 
         RCI_ind_pooledSD_30.30 = RCI_ind_pooledSD_klass, EN_30.30 = EN_klass, CSI_30.30 = CSI_klass) %>% 
  mutate(Mean_PC_30.30 = recode(Mean_PC_30.30, '-2' = 1L, '-1' = 0L, '0' = 0L, '1' = 0L, '2' = -1L))

y = EMA_5.5_Window %>% 
  select(ID, Mean_PC_klass, RCI_ind_preSD_klass, RCI_ind_pooledSD_klass, EN_klass, CSI_klass) %>% 
  dplyr::rename(Mean_PC_5.5_Window = Mean_PC_klass, RCI_ind_preSD_5.5_Window = RCI_ind_preSD_klass, 
         RCI_ind_pooledSD_5.5_Window = RCI_ind_pooledSD_klass, EN_5.5_Window = EN_klass, CSI_5.5_Window = CSI_klass) %>% 
  mutate(Mean_PC_5.5_Window = recode(Mean_PC_5.5_Window, '-2' = 1L, '-1' = 0L, '0' = 0L, '1' = 0L, '2' = -1L))

z = EMA_5.5_Days %>% 
  select(ID, Mean_PC_klass, RCI_ind_preSD_klass, RCI_ind_pooledSD_klass, EN_klass, CSI_klass) %>% 
  dplyr::rename(Mean_PC_5.5_Days = Mean_PC_klass, RCI_ind_preSD_5.5_Days = RCI_ind_preSD_klass, 
         RCI_ind_pooledSD_5.5_Days = RCI_ind_pooledSD_klass, EN_5.5_Days = EN_klass, CSI_5.5_Days = CSI_klass) %>% 
  mutate(Mean_PC_5.5_Days = recode(Mean_PC_5.5_Days, '-2' = 1L, '-1' = 0L, '0' = 0L, '1' = 0L, '2' = -1L))

temp = full_join(x, y, by = "ID") %>% 
  full_join(., z, "ID") %>% 
  select(-ID) %>% 
  dplyr::mutate(across(.cols = everything(), as.factor))

rnames = names(temp)


#view(dfSummary(temp))
#dfSummary(temp, plain.ascii = FALSE, style = 'grid', graph.magnif = 0.75, valid.col = FALSE, tmp.img.dir = "/tmp")
#dfSummary(temp)
print(dfSummary(temp, varnumbers = FALSE, plain.ascii = FALSE, style = 'grid', graph.magnif = 0.75, valid.col = FALSE, na.col = FALSE, display.labels = FALSE, silent = FALSE, headers = FALSE, footnote = NA, tmp.img.dir = "/tmp"), method = 'render')

Data Frame Summary

temp

Dimensions: 50 x 15
Duplicates: 21
Variable Stats / Values Freqs (% of Valid) Graph
Mean_PC_30.30 [factor] 1. -1 2. 0
12(24.0%)
38(76.0%)
RCI_ind_preSD_30.30 [factor] 1. -1 2. 0
21(42.0%)
29(58.0%)
RCI_ind_pooledSD_30.30 [factor] 1. -1 2. 0
15(30.0%)
35(70.0%)
EN_30.30 [factor] 1. -1 2. 0
24(48.0%)
26(52.0%)
CSI_30.30 [factor] 1. -1 2. 0
9(18.0%)
41(82.0%)
Mean_PC_5.5_Window [factor] 1. -1 2. 0 3. 1
13(26.0%)
36(72.0%)
1(2.0%)
RCI_ind_preSD_5.5_Window [factor] 1. -1 2. 0
21(42.0%)
29(58.0%)
RCI_ind_pooledSD_5.5_Window [factor] 1. -1 2. 0 3. 1
15(30.0%)
34(68.0%)
1(2.0%)
EN_5.5_Window [factor] 1. -1 2. 0 3. 1
24(48.0%)
25(50.0%)
1(2.0%)
CSI_5.5_Window [factor] 1. -1 2. 0 3. 1
12(24.0%)
37(74.0%)
1(2.0%)
Mean_PC_5.5_Days [factor] 1. -1 2. 0 3. 1
16(32.0%)
32(64.0%)
2(4.0%)
RCI_ind_preSD_5.5_Days [factor] 1. -1 2. 0 3. 1
23(46.0%)
24(48.0%)
3(6.0%)
RCI_ind_pooledSD_5.5_Days [factor] 1. -1 2. 0 3. 1
18(36.0%)
30(60.0%)
2(4.0%)
EN_5.5_Days [factor] 1. -1 2. 0 3. 1
25(50.0%)
23(46.0%)
2(4.0%)
CSI_5.5_Days [factor] 1. -1 2. 0 3. 1
12(24.0%)
36(72.0%)
2(4.0%)

Generated by summarytools 0.9.6 (R version 4.0.2)
2020-10-30


1.14.3 Übereinstimmung der Klassifikations-Häufigkeiten

Gesamt-Übereinstimmung

### Cohen´s Kappa
Agreement = matrix(ncol = 15, nrow = 15, dimnames = list(rnames, rnames))

for (i in 1:nrow(Agreement)) {
  for (j in 1:ncol(Agreement)) {
    x = eval(parse(text = paste0("temp$", names(temp[,i]))))
    y = eval(parse(text = paste0("temp$", names(temp[,j]))))
    
    Agreement[i,j] = CohenKappa(x = x, y = y)
  }
}

# mit plot.matrix::...
par(mar = c(5.1, 4.1, 4.1, 4.1)) # default c(5.1, 4.1, 4.1, 2.1)
plot(Agreement, col = heat.colors(n=5, rev=TRUE), fmt.cell = "%.2f", cex.axis = 0.5, cex = 0.7, las = 2, 
     key = list(cex.axis=0.6), ann = FALSE, breaks = c(0, 0.21, 0.41, 0.61, 0.81, 1));
  title(main = "Übereinstimmung (Cohen´s Kappa) der Klassifikationen")

### Prozentuale Übereinstimmung
Percentage_Agreement = matrix(ncol = 15, nrow = 15, dimnames = list(rnames, rnames))

for (i in 1:nrow(Percentage_Agreement)) {
  for (j in 1:ncol(Percentage_Agreement)) {
    x = eval(parse(text = paste0("temp$", names(temp[,i]))))
    y = eval(parse(text = paste0("temp$", names(temp[,j]))))
    
    Percentage_Agreement[i,j] = Agree(cbind(x, y))[1]
  }
}

# mit plot.matrix::...
par(mar = c(5.1, 4.1, 4.1, 4.1)) # default c(5.1, 4.1, 4.1, 2.1)
plot(Percentage_Agreement, col = heat.colors(n=4, rev=TRUE), fmt.cell = "%.2f", cex.axis = 0.5, cex = 0.7, las = 2, 
     key = list(cex.axis=0.6), ann = FALSE, breaks = c(0, 0.26, 0.51, 0.76, 1));
  title(main = "Prozentuale Übereinstimmung der Klassifikationen")

Übereinstimmung nur für Verbesserung (-1)

### Cohen´s Kappa
Agreement = matrix(ncol = 15, nrow = 15, dimnames = list(rnames, rnames))

for (i in 1:nrow(Agreement)) {
  for (j in 1:ncol(Agreement)) {
    x = eval(parse(text = paste0("temp$", names(temp[,i])))) %>% 
      dplyr::recode_factor(., '-1' = -1L)
    y = eval(parse(text = paste0("temp$", names(temp[,j])))) %>% 
      dplyr::recode_factor(., '-1' = -1L)
    
    Agreement[i,j] = CohenKappa(x = x, y = y, useNA = "ifany")
  }
}

# mit plot.matrix::...
par(mar = c(5.1, 4.1, 4.1, 4.1)) # default c(5.1, 4.1, 4.1, 2.1)
plot(Agreement, col = heat.colors(n=5, rev=TRUE), fmt.cell = "%.2f", cex.axis = 0.5, cex = 0.7, las = 2, 
     key = list(cex.axis=0.6), ann = FALSE, breaks = c(0, 0.21, 0.41, 0.61, 0.81, 1));
  title(main = "Übereinstimmung (Cohen´s Kappa): Verbesserung (-1)")

### Prozentuale Übereinstimmung
Percentage_Agreement = matrix(ncol = 15, nrow = 15, dimnames = list(rnames, rnames))

for (i in 1:nrow(Percentage_Agreement)) {
  for (j in 1:ncol(Percentage_Agreement)) {
    x = eval(parse(text = paste0("temp$", names(temp[,i]))))
    y = eval(parse(text = paste0("temp$", names(temp[,j]))))
    
    Percentage_Agreement[i,j] = length(which(x == -1L & y == -1L)) / 
      length(which(x == -1L | y == -1L))
  }
}

# mit plot.matrix::...
par(mar = c(5.1, 4.1, 4.1, 4.1)) # default c(5.1, 4.1, 4.1, 2.1)
plot(Percentage_Agreement, col = heat.colors(n=4, rev=TRUE), fmt.cell = "%.2f", cex.axis = 0.5, cex = 0.7, las = 2, 
     key = list(cex.axis=0.6), ann = FALSE, breaks = c(0, 0.26, 0.51, 0.76, 1));
  title(main = "Prozentuale Übereinstimmung: Verbesserung (-1)")

Übereinstimmung nur für Verschlechterung (1)

### Cohen´s Kappa
Agreement = matrix(ncol = 15, nrow = 15, dimnames = list(rnames, rnames))

for (i in 1:nrow(Agreement)) {
  for (j in 1:ncol(Agreement)) {
    x = eval(parse(text = paste0("temp$", names(temp[,i])))) %>% 
      recode_factor(., '1' = 1L)
    y = eval(parse(text = paste0("temp$", names(temp[,j])))) %>% 
      recode_factor(., '1' = 1L)
    
    Agreement[i,j] = CohenKappa(x = x, y = y, useNA = "ifany")
  }
}

# mit plot.matrix::...
par(mar = c(5.1, 4.1, 4.1, 4.1)) # default c(5.1, 4.1, 4.1, 2.1)
plot(Agreement, col = heat.colors(n=5, rev=TRUE), fmt.cell = "%.2f", cex.axis = 0.5, cex = 0.7, las = 2, 
     key = list(cex.axis=0.6), ann = FALSE, breaks = c(0, 0.21, 0.41, 0.61, 0.81, 1));
  title(main = "Übereinstimmung (Cohen´s Kappa): Verschlechterung (1)")

### Prozentuale Übereinstimmung
Percentage_Agreement = matrix(ncol = 15, nrow = 15, dimnames = list(rnames, rnames))

for (i in 1:nrow(Percentage_Agreement)) {
  for (j in 1:ncol(Percentage_Agreement)) {
    x = eval(parse(text = paste0("temp$", names(temp[,i]))))
    y = eval(parse(text = paste0("temp$", names(temp[,j]))))
    
    Percentage_Agreement[i,j] = length(which(x == 1L & y == 1L)) / 
      length(which(x == 1L | y == 1L))
  }
}

# mit plot.matrix::...
par(mar = c(5.1, 4.1, 4.1, 4.1)) # default c(5.1, 4.1, 4.1, 2.1)
plot(Percentage_Agreement, col = heat.colors(n=4, rev=TRUE), fmt.cell = "%.2f", cex.axis = 0.5, cex = 0.7, las = 2, 
     key = list(cex.axis=0.6), ann = FALSE, breaks = c(0, 0.26, 0.51, 0.76, 1));
  title(main = "Prozentuale Übereinstimmung: Verschlechterung (1)")


1.15 Sensitivität und Spezifität der Klassifikationsmethoden

Diagnostische Sensitivität und Spezifität einer “neuen” Testmethode im Vergleich zu einer “Goldstandard”-Testmethode:
Sensitivität = Wahrscheinlichkeit für ein richtig-positives Testergebnis
Spezifität = Wahrscheinlichkeit für ein richtig-negatives Testergebnis

\[ Sensitivity = \frac{\sum{\text{True Positives}}} {\sum{\text{True Positives}} + \sum{\text{False Negatives}}} \]

\[ Specificity = \frac{\sum{\text{True Negatives}}} {\sum{\text{True Negatives}} + \sum{\text{False Positives}}} \]

Sensitivität & Spezifität gegenüber Veränderung:
Absolute Häufigkeiten der Veränderungs-Klassifikationen (verändert vs. nicht verändert) der Klassifikationsmethoden im Vergleich zur klinischen Signifikanz CSI (je 30 MZP) als “Goldstandard”:

SenSpez = tibble(Method = colnames(temp),
                 n_Changed = as.integer(NA),
                 n_Unchanged = as.integer(NA),
                 Total = as.integer(NA),
                 Sensitivity = as.numeric(NA),
                 Specificity = as.numeric(NA))

for (i in 1:nrow(SenSpez)) {
  x = eval(parse(text = paste0("temp$", names(temp[,i]))))
  SenSpez[i,"n_Changed"] = temp %>% summarise(., sum(x %in% c(-1,1))) %>% as.integer()
}

for (i in 1:nrow(SenSpez)) {
  x = eval(parse(text = paste0("temp$", names(temp[,i]))))
  SenSpez[i,"n_Unchanged"] = temp %>% summarise(., sum(x == 0)) %>% as.integer()
}

for (i in 1:nrow(SenSpez)) {
  x = eval(parse(text = paste0("temp$", names(temp[,i]))))
  SenSpez[i,"Total"] = temp %>% summarise(., sum(!is.na(x))) %>% as.integer()
}

for (i in 1:nrow(SenSpez)) {
  x = eval(parse(text = paste0("temp$", names(temp[,i]))))
  SenSpez[i,"Sensitivity"] = sum(x %in% c(-1,1) & temp$CSI_30.30 %in% c(-1,1)) /
                      (sum(x %in% c(-1,1) & temp$CSI_30.30 %in% c(-1,1)) + sum(x == 0 & temp$CSI_30.30 %in% c(-1,1)))
}

for (i in 1:nrow(SenSpez)) {
  x = eval(parse(text = paste0("temp$", names(temp[,i]))))
  SenSpez[i,"Specificity"] = sum(x == 0 & temp$CSI_30.30 == 0) /
                      (sum(x == 0 & temp$CSI_30.30 == 0) + sum(x %in% c(-1,1) & temp$CSI_30.30 == 0))
}

SenSpez$Sensitivity = round(SenSpez$Sensitivity, digits = 3)
SenSpez$Specificity = round(SenSpez$Specificity, digits = 3)

SenSpez %>% 
  kable() %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = FALSE)
Method n_Changed n_Unchanged Total Sensitivity Specificity
Mean_PC_30.30 12 38 50 1.000 0.927
RCI_ind_preSD_30.30 21 29 50 1.000 0.707
RCI_ind_pooledSD_30.30 15 35 50 1.000 0.854
EN_30.30 24 26 50 1.000 0.634
CSI_30.30 9 41 50 1.000 1.000
Mean_PC_5.5_Window 14 36 50 0.889 0.854
RCI_ind_preSD_5.5_Window 21 29 50 1.000 0.707
RCI_ind_pooledSD_5.5_Window 16 34 50 0.889 0.805
EN_5.5_Window 25 25 50 1.000 0.610
CSI_5.5_Window 13 37 50 0.889 0.878
Mean_PC_5.5_Days 18 32 50 0.889 0.756
RCI_ind_preSD_5.5_Days 26 24 50 1.000 0.585
RCI_ind_pooledSD_5.5_Days 20 30 50 0.889 0.707
EN_5.5_Days 27 23 50 1.000 0.561
CSI_5.5_Days 14 36 50 0.889 0.854
graphics::barplot(SenSpez$Sensitivity ~ SenSpez$Method, col = "dodgerblue", las = 2, cex.names = 0.7, 
                  main = "Sensitivity to Change (Improvement & Deterioration)")
graphics::barplot(SenSpez$Specificity ~ SenSpez$Method, col = "dodgerblue", las = 2, cex.names = 0.7,
                  main = "Specificity to Change (Improvement & Deterioration)")


Sensitivität & Spezifität gegenüber Verbesserung:
Absolute Häufigkeiten der Veränderungs-Klassifikationen (verbessert vs. nicht verbessert) der Klassifikationsmethoden im Vergleich zur klinischen Signifikanz CSI (je 30 MZP) als “Goldstandard”:

SenSpez = tibble(Method = colnames(temp),
                 n_Improved = as.integer(NA),
                 n_NotImproved = as.integer(NA),
                 Total = as.integer(NA),
                 Sensitivity_Imp = as.numeric(NA),
                 Specificity_Imp = as.numeric(NA))

for (i in 1:nrow(SenSpez)) {
  x = eval(parse(text = paste0("temp$", names(temp[,i]))))
  SenSpez[i,"n_Improved"] = temp %>% summarise(., sum(x == -1)) %>% as.integer()
}

for (i in 1:nrow(SenSpez)) {
  x = eval(parse(text = paste0("temp$", names(temp[,i]))))
  SenSpez[i,"n_NotImproved"] = temp %>% summarise(., sum(x %in% c(-1,1))) %>% as.integer()
}

for (i in 1:nrow(SenSpez)) {
  x = eval(parse(text = paste0("temp$", names(temp[,i]))))
  SenSpez[i,"Total"] = temp %>% summarise(., sum(!is.na(x))) %>% as.integer()
}

for (i in 1:nrow(SenSpez)) {
  x = eval(parse(text = paste0("temp$", names(temp[,i]))))
  SenSpez[i,"Sensitivity_Imp"] = sum(x == -1 & temp$CSI_30.30 == -1) /
                      (sum(x == -1 & temp$CSI_30.30 == -1) + sum(x %in% c(0,1) & temp$CSI_30.30 == -1))
}

for (i in 1:nrow(SenSpez)) {
  x = eval(parse(text = paste0("temp$", names(temp[,i]))))
  SenSpez[i,"Specificity_Imp"] = sum(x %in% c(0,1) & temp$CSI_30.30 %in% c(0,1)) /
                      (sum(x %in% c(0,1) & temp$CSI_30.30 %in% c(0,1)) + sum(x == -1 & temp$CSI_30.30 %in% c(0,1)))
}

SenSpez$Sensitivity_Imp = round(SenSpez$Sensitivity_Imp, digits = 3)
SenSpez$Specificity_Imp = round(SenSpez$Specificity_Imp, digits = 3)

SenSpez %>% 
  kable() %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = FALSE)
Method n_Improved n_NotImproved Total Sensitivity_Imp Specificity_Imp
Mean_PC_30.30 12 12 50 1.000 0.927
RCI_ind_preSD_30.30 21 21 50 1.000 0.707
RCI_ind_pooledSD_30.30 15 15 50 1.000 0.854
EN_30.30 24 24 50 1.000 0.634
CSI_30.30 9 9 50 1.000 1.000
Mean_PC_5.5_Window 13 14 50 0.889 0.878
RCI_ind_preSD_5.5_Window 21 21 50 1.000 0.707
RCI_ind_pooledSD_5.5_Window 15 16 50 0.889 0.829
EN_5.5_Window 24 25 50 1.000 0.634
CSI_5.5_Window 12 13 50 0.889 0.902
Mean_PC_5.5_Days 16 18 50 0.889 0.805
RCI_ind_preSD_5.5_Days 23 26 50 1.000 0.659
RCI_ind_pooledSD_5.5_Days 18 20 50 0.889 0.756
EN_5.5_Days 25 27 50 1.000 0.610
CSI_5.5_Days 12 14 50 0.889 0.902
graphics::barplot(SenSpez$Sensitivity_Imp ~ SenSpez$Method, col = "dodgerblue", las = 2, cex.names = 0.7, 
                  main = "Sensitivity to Improvement")
graphics::barplot(SenSpez$Specificity_Imp ~ SenSpez$Method, col = "dodgerblue", las = 2, cex.names = 0.7,
                  main = "Specificity to Improvement")


Sensitivität & Spezifität gegenüber Verschlechterung:
Absolute Häufigkeiten der Veränderungs-Klassifikationen (verschlechtert vs. nicht verschlechtert) der Klassifikationsmethoden im Vergleich zur klinischen Signifikanz CSI (je 30 MZP) als “Goldstandard”:

SenSpez = tibble(Method = colnames(temp),
                 n_Deteriorated = as.integer(NA),
                 n_NotDeteriorated = as.integer(NA),
                 Total = as.integer(NA),
                 Sensitivity_Det = as.numeric(NA),
                 Specificity_Det = as.numeric(NA))

for (i in 1:nrow(SenSpez)) {
  x = eval(parse(text = paste0("temp$", names(temp[,i]))))
  SenSpez[i,"n_Deteriorated"] = temp %>% summarise(., sum(x == 1)) %>% as.integer()
}

for (i in 1:nrow(SenSpez)) {
  x = eval(parse(text = paste0("temp$", names(temp[,i]))))
  SenSpez[i,"n_NotDeteriorated"] = temp %>% summarise(., sum(x %in% c(-1,0))) %>% as.integer()
}

for (i in 1:nrow(SenSpez)) {
  x = eval(parse(text = paste0("temp$", names(temp[,i]))))
  SenSpez[i,"Total"] = temp %>% summarise(., sum(!is.na(x))) %>% as.integer()
}

for (i in 1:nrow(SenSpez)) {
  x = eval(parse(text = paste0("temp$", names(temp[,i]))))
  SenSpez[i,"Sensitivity_Det"] = sum(x == 1 & temp$CSI_30.30 == 1) /
                      (sum(x == 1 & temp$CSI_30.30 == 1) + sum(x %in% c(-1,0) & temp$CSI_30.30 == 1))
}

for (i in 1:nrow(SenSpez)) {
  x = eval(parse(text = paste0("temp$", names(temp[,i]))))
  SenSpez[i,"Specificity_Det"] = sum(x %in% c(-1,0) & temp$CSI_30.30 %in% c(-1,0)) /
                      (sum(x %in% c(-1,0) & temp$CSI_30.30 %in% c(-1,0)) + sum(x == 1 & temp$CSI_30.30 %in% c(-1,0)))
}

SenSpez$Sensitivity_Det = round(SenSpez$Sensitivity_Det, digits = 3)
SenSpez$Specificity_Det = round(SenSpez$Specificity_Det, digits = 3)

SenSpez %>% 
  kable() %>%
  kable_styling(bootstrap_options = c("striped", "hover", "condensed"), full_width = FALSE)
Method n_Deteriorated n_NotDeteriorated Total Sensitivity_Det Specificity_Det
Mean_PC_30.30 0 50 50 NaN 1.00
RCI_ind_preSD_30.30 0 50 50 NaN 1.00
RCI_ind_pooledSD_30.30 0 50 50 NaN 1.00
EN_30.30 0 50 50 NaN 1.00
CSI_30.30 0 50 50 NaN 1.00
Mean_PC_5.5_Window 1 49 50 NaN 0.98
RCI_ind_preSD_5.5_Window 0 50 50 NaN 1.00
RCI_ind_pooledSD_5.5_Window 1 49 50 NaN 0.98
EN_5.5_Window 1 49 50 NaN 0.98
CSI_5.5_Window 1 49 50 NaN 0.98
Mean_PC_5.5_Days 2 48 50 NaN 0.96
RCI_ind_preSD_5.5_Days 3 47 50 NaN 0.94
RCI_ind_pooledSD_5.5_Days 2 48 50 NaN 0.96
EN_5.5_Days 2 48 50 NaN 0.96
CSI_5.5_Days 2 48 50 NaN 0.96
#graphics::barplot(SenSpez$Sensitivity_Det ~ SenSpez$Method, col = "dodgerblue", las = 2, cex.names = 0.7, 
#                  main = "Sensitivity to Deterioration")
graphics::barplot(SenSpez$Specificity_Det ~ SenSpez$Method, col = "dodgerblue", las = 2, cex.names = 0.7,
                  main = "Specificity to Deterioration")


1.16 Jackknife-Methode zum Resampling von Messzeitpunkten

Statt wenige zufällige MZP-Kombinationen zu ziehen und diese dann mit den “wahren” Schätzwerten und Klassifikationen (= berechnet anhand der gesamten Intervalle mit je 30 MZP) zu vergleichen, sollen die empirische Verteilung der Parameter und somit der Schätzfehler über Resampling-Methoden wie Jackknife-Verfahren und Bootstrapping berechnet werden.

Percentage Change (PC)

###### EMA_30.30
n = 30

Mean_PC = function(x, ID_df) {(1-((mean(ID_df[x,2])) / (mean(ID_df[x,1])))) * 100}

for (i in 1:nrow(EMA_30.30)) {
  df = data.frame(PRE = as.numeric(EMA_30.30[i,pre_30mzp]), POST = as.numeric(EMA_30.30[i,post_30mzp]))
  
  EMA_30.30[i,"Mean_PC_jse"] = jackknife(1:n, Mean_PC, df)$jack.se
  EMA_30.30[i,"Mean_PC_jbias"] = jackknife(1:n, Mean_PC, df)$jack.bias
  message(i)
}

EMA_30.30_Mean_PC_JK = EMA_30.30 %>% 
  select(ID, Mean_PC_jse, Mean_PC_jbias)
save(EMA_30.30_Mean_PC_JK, file = "Jackknife/EMA_30.30_Mean_PC_JK_k20_n50.RData")

###### EMA_5.5_Window
n = 5

Mean_PC = function(x, ID_df) {(1-((mean(ID_df[x,2])) / (mean(ID_df[x,1])))) * 100}

for (i in 1:nrow(EMA_5.5_Window)) {
  df = data.frame(PRE = as.numeric(EMA_5.5_Window[i,pre_5mzp]), POST = as.numeric(EMA_5.5_Window[i,post_5mzp]))
  
  EMA_5.5_Window[i,"Mean_PC_jse"] = jackknife(1:n, Mean_PC, df)$jack.se
  EMA_5.5_Window[i,"Mean_PC_jbias"] = jackknife(1:n, Mean_PC, df)$jack.bias
  message(i)
}

EMA_5.5_Window_Mean_PC_JK = EMA_5.5_Window %>% 
  select(ID, Mean_PC_jse, Mean_PC_jbias)
save(EMA_5.5_Window_Mean_PC_JK, file = "Jackknife/EMA_5.5_Window_Mean_PC_JK_k20_n50.RData")

###### EMA_5.5_Days
n = 5

Mean_PC = function(x, ID_df) {(1-((mean(ID_df[x,2])) / (mean(ID_df[x,1])))) * 100}

for (i in 1:nrow(EMA_5.5_Days)) {
  df = data.frame(PRE = as.numeric(EMA_5.5_Days[i,pre_5mzp]), POST = as.numeric(EMA_5.5_Days[i,post_5mzp]))
  
  EMA_5.5_Days[i,"Mean_PC_jse"] = jackknife(1:n, Mean_PC, df)$jack.se
  EMA_5.5_Days[i,"Mean_PC_jbias"] = jackknife(1:n, Mean_PC, df)$jack.bias
  message(i)
}

EMA_5.5_Days_Mean_PC_JK = EMA_5.5_Days %>% 
  select(ID, Mean_PC_jse, Mean_PC_jbias)
save(EMA_5.5_Days_Mean_PC_JK, file = "Jackknife/EMA_5.5_Days_Mean_PC_JK_k20_n50.RData")
load("Jackknife/EMA_30.30_Mean_PC_JK_k20_n50.RData")
load("Jackknife/EMA_5.5_Window_Mean_PC_JK_k20_n50.RData")
load("Jackknife/EMA_5.5_Days_Mean_PC_JK_k20_n50.RData")

EMA_30.30 = full_join(EMA_30.30, EMA_30.30_Mean_PC_JK, by = "ID")
EMA_5.5_Window = full_join(EMA_5.5_Window, EMA_5.5_Window_Mean_PC_JK, by = "ID")
EMA_5.5_Days = full_join(EMA_5.5_Days, EMA_5.5_Days_Mean_PC_JK, by = "ID")

temp = tibble(Jackknife_SE = c(EMA_30.30$Mean_PC_jse, EMA_5.5_Window$Mean_PC_jse, EMA_5.5_Days$Mean_PC_jse),
              Datasets = rep(c("EMA_30.30", "EMA_5.5_Window", "EMA_5.5_Days"), each = length(EMA_30.30$Mean_PC_jse)))

temp %>%
  ggplot(aes(x = Jackknife_SE, fill = Datasets)) +
    geom_histogram(alpha = 0.2, binwidth = 1, position = "identity") +
    labs(x = "Jackknife SE of Mean Percentage Change", y = "Cases")

#ggplot(temp, aes(x = Datasets, y = Jackknife_SE)) + 
#  geom_boxplot(na.rm = TRUE) + 
#  ggtitle("Jackknife SEs") +
#  xlab("Dataset")


temp = tibble(Jackknife_Bias = c(EMA_30.30$Mean_PC_jbias, EMA_5.5_Window$Mean_PC_jbias, EMA_5.5_Days$Mean_PC_jbias),
              Datasets = rep(c("EMA_30.30", "EMA_5.5_Window", "EMA_5.5_Days"), each = length(EMA_30.30$Mean_PC_jbias)))

temp %>%
  ggplot(aes(x = Jackknife_Bias, fill = Datasets)) +
    geom_histogram(alpha = 0.2, binwidth = 1, position = "identity") +
    labs(x = "Jackknife Bias of Mean Percentage Change", y = "Cases")

#ggplot(temp, aes(x = Datasets, y = Jackknife_Bias)) + 
#  geom_boxplot(na.rm = TRUE) + 
#  ggtitle("Jackknife Biases") +
#  xlab("Dataset")

RCI(ind) nur mit SD aus dem individuellen Pre-Intervall

###### EMA_30.30
n = 30

RCI_ind_preSD = function(x, ID_df) {(mean(ID_df[x,2]) - mean(ID_df[x,1])) / 
    sqrt(2 * (sd(ID_df[x,1]) * sqrt(1 - EMA_5.5_Alpha))^2)}

for (i in 1:nrow(EMA_30.30)) {
  df = data.frame(PRE = as.numeric(EMA_30.30[i,pre_30mzp]), POST = as.numeric(EMA_30.30[i,post_30mzp]))
  
  EMA_30.30[i,"RCI_ind_preSD_jse"] = jackknife(1:n, RCI_ind_preSD, df)$jack.se
  EMA_30.30[i,"RCI_ind_preSD_jbias"] = jackknife(1:n, RCI_ind_preSD, df)$jack.bias
  message(i)
}

EMA_30.30_RCI_ind_preSD_JK = EMA_30.30 %>% 
  select(ID, RCI_ind_preSD_jse, RCI_ind_preSD_jbias)
save(EMA_30.30_RCI_ind_preSD_JK, file = "Jackknife/EMA_30.30_RCI_ind_preSD_JK_k20_n50.RData")

###### EMA_5.5_Window
n = 5

RCI_ind_preSD = function(x, ID_df) {(mean(ID_df[x,2]) - mean(ID_df[x,1])) / 
    sqrt(2 * (sd(ID_df[x,1]) * sqrt(1 - EMA_5.5_Alpha))^2)}

for (i in 1:nrow(EMA_5.5_Window)) {
  df = data.frame(PRE = as.numeric(EMA_5.5_Window[i,pre_5mzp]), POST = as.numeric(EMA_5.5_Window[i,post_5mzp]))
  
  EMA_5.5_Window[i,"RCI_ind_preSD_jse"] = jackknife(1:n, RCI_ind_preSD, df)$jack.se
  EMA_5.5_Window[i,"RCI_ind_preSD_jbias"] = jackknife(1:n, RCI_ind_preSD, df)$jack.bias
  message(i)
}

EMA_5.5_Window_RCI_ind_preSD_JK = EMA_5.5_Window %>% 
  select(ID, RCI_ind_preSD_jse, RCI_ind_preSD_jbias)
save(EMA_5.5_Window_RCI_ind_preSD_JK, file = "Jackknife/EMA_5.5_Window_RCI_ind_preSD_JK_k20_n50.RData")

###### EMA_5.5_Days
n = 5

RCI_ind_preSD = function(x, ID_df) {(mean(ID_df[x,2]) - mean(ID_df[x,1])) / 
    sqrt(2 * (sd(ID_df[x,1]) * sqrt(1 - EMA_5.5_Alpha))^2)}

for (i in 1:nrow(EMA_5.5_Days)) {
  df = data.frame(PRE = as.numeric(EMA_5.5_Days[i,pre_5mzp]), POST = as.numeric(EMA_5.5_Days[i,post_5mzp]))
  
  EMA_5.5_Days[i,"RCI_ind_preSD_jse"] = jackknife(1:n, RCI_ind_preSD, df)$jack.se
  EMA_5.5_Days[i,"RCI_ind_preSD_jbias"] = jackknife(1:n, RCI_ind_preSD, df)$jack.bias
  message(i)
}

EMA_5.5_Days_RCI_ind_preSD_JK = EMA_5.5_Days %>% 
  select(ID, RCI_ind_preSD_jse, RCI_ind_preSD_jbias)
save(EMA_5.5_Days_RCI_ind_preSD_JK, file = "Jackknife/EMA_5.5_Days_RCI_ind_preSD_JK_k20_n50.RData")
load("Jackknife/EMA_30.30_RCI_ind_preSD_JK_k20_n50.RData")
load("Jackknife/EMA_5.5_Window_RCI_ind_preSD_JK_k20_n50.RData")
load("Jackknife/EMA_5.5_Days_RCI_ind_preSD_JK_k20_n50.RData")

EMA_30.30 = full_join(EMA_30.30, EMA_30.30_RCI_ind_preSD_JK, by = "ID")
EMA_5.5_Window = full_join(EMA_5.5_Window, EMA_5.5_Window_RCI_ind_preSD_JK, by = "ID")
EMA_5.5_Days = full_join(EMA_5.5_Days, EMA_5.5_Days_RCI_ind_preSD_JK, by = "ID")

temp = tibble(Jackknife_SE = c(EMA_30.30$RCI_ind_preSD_jse, EMA_5.5_Window$RCI_ind_preSD_jse, EMA_5.5_Days$RCI_ind_preSD_jse),
              Datasets = rep(c("EMA_30.30", "EMA_5.5_Window", "EMA_5.5_Days"), each = length(EMA_30.30$RCI_ind_preSD_jse)))

temp %>%
  ggplot(aes(x = Jackknife_SE, fill = Datasets)) +
    geom_histogram(alpha = 0.2, binwidth = 1, position = "identity") +
    labs(x = "Jackknife SE of RCI(ind) With Pre-SDs", y = "Cases")

#ggplot(temp, aes(x = Datasets, y = Jackknife_SE)) + 
#  geom_boxplot(na.rm = TRUE) + 
#  ggtitle("Jackknife SEs") +
#  xlab("Dataset")


temp = tibble(Jackknife_Bias = c(EMA_30.30$RCI_ind_preSD_jbias, EMA_5.5_Window$RCI_ind_preSD_jbias,
                                 EMA_5.5_Days$RCI_ind_preSD_jbias),
              Datasets = rep(c("EMA_30.30", "EMA_5.5_Window", "EMA_5.5_Days"), each = length(EMA_30.30$RCI_ind_preSD_jbias)))

temp %>%
  ggplot(aes(x = Jackknife_Bias, fill = Datasets)) +
    geom_histogram(alpha = 0.2, binwidth = 1, position = "identity") +
    labs(x = "Jackknife Bias of RCI(ind) With Pre-SDs", y = "Cases")

#ggplot(temp, aes(x = Datasets, y = Jackknife_Bias)) + 
#  geom_boxplot(na.rm = TRUE) + 
#  ggtitle("Jackknife Biases") +
#  xlab("Dataset")

RCI(ind) mit pooled SDs aus beiden individuellen Intervallen

###### EMA_30.30
n = 30

RCI_ind_pooledSD = function(x, ID_df) {(mean(ID_df[x,2]) - mean(ID_df[x,1])) / 
    sqrt((sd(ID_df[x,1])^ 2 + sd(ID_df[x,2])^ 2) * (1 - EMA_5.5_Alpha))}

for (i in 1:nrow(EMA_30.30)) {
  df = data.frame(PRE = as.numeric(EMA_30.30[i,pre_30mzp]), POST = as.numeric(EMA_30.30[i,post_30mzp]))
  
  EMA_30.30[i,"RCI_ind_pooledSD_jse"] = jackknife(1:n, RCI_ind_pooledSD, df)$jack.se
  EMA_30.30[i,"RCI_ind_pooledSD_jbias"] = jackknife(1:n, RCI_ind_pooledSD, df)$jack.bias
  message(i)
}

EMA_30.30_RCI_ind_pooledSD_JK = EMA_30.30 %>% 
  select(ID, RCI_ind_pooledSD_jse, RCI_ind_pooledSD_jbias)
save(EMA_30.30_RCI_ind_pooledSD_JK, file = "Jackknife/EMA_30.30_RCI_ind_pooledSD_JK_k20_n50.RData")

###### EMA_5.5_Window
n = 5

RCI_ind_pooledSD = function(x, ID_df) {(mean(ID_df[x,2]) - mean(ID_df[x,1])) / 
    sqrt((sd(ID_df[x,1])^ 2 + sd(ID_df[x,2])^ 2) * (1 - EMA_5.5_Alpha))}

for (i in 1:nrow(EMA_5.5_Window)) {
  df = data.frame(PRE = as.numeric(EMA_5.5_Window[i,pre_5mzp]), POST = as.numeric(EMA_5.5_Window[i,post_5mzp]))
  
  EMA_5.5_Window[i,"RCI_ind_pooledSD_jse"] = jackknife(1:n, RCI_ind_pooledSD, df)$jack.se
  EMA_5.5_Window[i,"RCI_ind_pooledSD_jbias"] = jackknife(1:n, RCI_ind_pooledSD, df)$jack.bias
  message(i)
}

EMA_5.5_Window_RCI_ind_pooledSD_JK = EMA_5.5_Window %>% 
  select(ID, RCI_ind_pooledSD_jse, RCI_ind_pooledSD_jbias)
save(EMA_5.5_Window_RCI_ind_pooledSD_JK, file = "Jackknife/EMA_5.5_Window_RCI_ind_pooledSD_JK_k20_n50.RData")

###### EMA_5.5_Days
n = 5

RCI_ind_pooledSD = function(x, ID_df) {(mean(ID_df[x,2]) - mean(ID_df[x,1])) / 
    sqrt((sd(ID_df[x,1])^ 2 + sd(ID_df[x,2])^ 2) * (1 - EMA_5.5_Alpha))}

for (i in 1:nrow(EMA_5.5_Days)) {
  df = data.frame(PRE = as.numeric(EMA_5.5_Days[i,pre_5mzp]), POST = as.numeric(EMA_5.5_Days[i,post_5mzp]))
  
  EMA_5.5_Days[i,"RCI_ind_pooledSD_jse"] = jackknife(1:n, RCI_ind_pooledSD, df)$jack.se
  EMA_5.5_Days[i,"RCI_ind_pooledSD_jbias"] = jackknife(1:n, RCI_ind_pooledSD, df)$jack.bias
  message(i)
}

EMA_5.5_Days_RCI_ind_pooledSD_JK = EMA_5.5_Days %>% 
  select(ID, RCI_ind_pooledSD_jse, RCI_ind_pooledSD_jbias)
save(EMA_5.5_Days_RCI_ind_pooledSD_JK, file = "Jackknife/EMA_5.5_Days_RCI_ind_pooledSD_JK_k20_n50.RData")
load("Jackknife/EMA_30.30_RCI_ind_pooledSD_JK_k20_n50.RData")
load("Jackknife/EMA_5.5_Window_RCI_ind_pooledSD_JK_k20_n50.RData")
load("Jackknife/EMA_5.5_Days_RCI_ind_pooledSD_JK_k20_n50.RData")

EMA_30.30 = full_join(EMA_30.30, EMA_30.30_RCI_ind_pooledSD_JK, by = "ID")
EMA_5.5_Window = full_join(EMA_5.5_Window, EMA_5.5_Window_RCI_ind_pooledSD_JK, by = "ID")
EMA_5.5_Days = full_join(EMA_5.5_Days, EMA_5.5_Days_RCI_ind_pooledSD_JK, by = "ID")

temp = tibble(Jackknife_SE = c(EMA_30.30$RCI_ind_pooledSD_jse, EMA_5.5_Window$RCI_ind_pooledSD_jse,
                               EMA_5.5_Days$RCI_ind_pooledSD_jse),
              Datasets = rep(c("EMA_30.30", "EMA_5.5_Window", "EMA_5.5_Days"), each = length(EMA_30.30$RCI_ind_pooledSD_jse)))

temp %>%
  ggplot(aes(x = Jackknife_SE, fill = Datasets)) +
    geom_histogram(alpha = 0.2, binwidth = 1, position = "identity") +
    labs(x = "Jackknife SE of RCI(ind) With Pooled SDs", y = "Cases")

#ggplot(temp, aes(x = Datasets, y = Jackknife_SE)) + 
#  geom_boxplot(na.rm = TRUE) + 
#  ggtitle("Jackknife SEs") +
#  xlab("Dataset")


temp = tibble(Jackknife_Bias = c(EMA_30.30$RCI_ind_pooledSD_jbias, EMA_5.5_Window$RCI_ind_pooledSD_jbias,
                               EMA_5.5_Days$RCI_ind_pooledSD_jbias),
              Datasets = rep(c("EMA_30.30", "EMA_5.5_Window", "EMA_5.5_Days"), each = length(EMA_30.30$RCI_ind_pooledSD_jbias)))

temp %>%
  ggplot(aes(x = Jackknife_Bias, fill = Datasets)) +
    geom_histogram(alpha = 0.2, binwidth = 1, position = "identity") +
    labs(x = "Jackknife Bias of RCI(ind) With Pooled SDs", y = "Cases")

#ggplot(temp, aes(x = Datasets, y = Jackknife_Bias)) + 
#  geom_boxplot(na.rm = TRUE) + 
#  ggtitle("Jackknife Biases") +
#  xlab("Dataset")